Instead of going over an example of how to add each of the components to our GUI, I'm going to go over how they work, and then give an example them.
Lets start off with JButtons. Before our Main() object, we will declare our button
private JButton myButton = new JButton("My first button"):
And now, add this to your Main() object
add(myButton);
And now you should have a button! It wont do anything, but its nice to have.
Next are labels.
private JLabel myLabel = new JLabel("My first label!");
and just add(label);
Getting a hang of it now?
And finally, text areas.
JTextArea area = new JTextArea(1, 3);
The numbers are the size of the area, charecter wise. Be sure to add(area) to your program!
Thanks
-Steve
YOU ARE READING
Java Swing GUI Development
Non-FictionLearn all the necessities of Java Swing GUI development right here, from me, not some huge cooperate company, that can't find a good way to get the message across. Learn it here, learn it once.
