This week's book giveaway is in the General Computing forum. We're giving away four copies of Arduino in Action and have Martin Evans, Joshua Noble, and Jordan Hochenbaum on-line! See this thread for details.
I've been trying to display a frame, with two buttons using swing. The file compiled, and when I run it, it displays a grey empty box(frame). I tried 'swing' examples from a book, and again, grey box, with nothing in it. I rewrote the file using awt, and it works fine. I am using SDK 1.4.0 beta 3, on WIN98SE. Any idea? Berko
Why don't you show us your code. Are you by chance creating an Applet with Swing? If so, you need the plug in to get it to run.
dodo dimitrius
Greenhorn
Joined: Dec 04, 2001
Posts: 24
posted
0
Hi guys! Rashid, I tried your code, and the result is the same, the frame (grey box) displays with no elements on it(button and textfield). Paul, here is my code: import java.awt.*; import javax.swing.*; public class BoxStacker { public static void main(String[] args) { JPanel p = new JPanel(); p.add(new JButton("Save")); p.add(new JButton("Hello")); JFrame f = new JFrame("Berko"); f.getContentPane().add(p); f.setSize(200,200); f.setVisible(true); } } It displays the frame with the name on it, but there is no buttons inside, just grey empy box. Any idea? Berko
Rashid Ali
Ranch Hand
Joined: Jan 16, 2001
Posts: 349
posted
0
Dear Berko I tried your code and it works fine shows two buttons on the little frame having title 'Save' and 'Hello'. I did not made any change in your code just compiled and run. I think there's some problem with you J2SDK1.4 due to which it's not working on your computer. Reinstall it again and try your code it will definitely works fine. Hope it helps. Rashid Ali