Other than the fact that I am just learning Java and am yet to figure out what I am doing, can you tell me why the following does not put the panel and button on the frame? I get no compiler errors when I run this but all that displays is the frame. This project is just for learning's sake so I am not desperate but before I crush my screen, I would be obliged if someone could assist me (and I don't like replacing screens).
JPanel panel1 = new JPanel(); //Create a panel to add to the frame JButton button1 = new JButton("Submit"); //Create a button to add to a panel panel1.add(button1); //Add the button to the panel JLabel label1 = new JLabel("Login"); //Create label to add to panel panel1.add(label1); //Add label to panel
//Add panel components to frame theScreen.getContentPane().add(BorderLayout.CENTER, panel1);
} [ May 21, 2005: Message edited by: Al Wells ]
Joined: Apr 18, 2005
BTW, I failed to copy all of the imports. I do have import javax.swing.*; in the first line. The awt and awt.event imports are for other functions that I will be attempting once I can get this one to work.
For future reference, we have a forum that specializes in GUI programming. You may want to post similar questions there in the future. Of course, you should feel free to come back here with any general Java questions you have.