Just like we did yesterday, we are going to add a button to our program. It seems simple enough that all we would need to do is to add this line of code
b = new Button("Zoinks!"); //declare button
f1.add(b); //add button to frame
just above this line of code
f1.show( );
but unfortunately its not that simple. To put any sort of compoent on an application GUI, you have to use a LAYOUT MANAGER. The simplest kind is a "Flow Layout"; this is what you would type:
f1.setLayout(new FlowLayout());
and you should write inside the constructor area, preferably ABOVE where you typed in the code for adding a Button
OK, let's put all this together, and see what we get!
cheers,
Uncle Paulie
Monday, February 2, 2009
Subscribe to:
Post Comments (Atom)

No comments:
Post a Comment