|
-
February 15th, 2009, 05:02 PM
#1
why do the buttons not show?
I tried to create a simple GUI,but but my buttons and label dont show.I tried rearranging my lines of code in the launchFrame method but i couldnt get the correct result.I want to create a GUI with three buttons aligned ,a panel on top and a label under the buttons.Here are the lines of code i used
import java.awt.*;
public class FlowExample
{
private Panel p;
private Button b1;
private Button b2;
private Button b3;
private Label l;
private Frame f;
public FlowExample()
{
p = new Panel();
b1 = new Button(" Blue ");
b2 = new Button(" Red ");
b3 = new Button("Yellow");
l = new Label();
f = new Frame("Choose Color");
}
public void launchFrame()
{
p.setSize(500,50);
p.setBackground(Color.green);
f.add(p, BorderLayout.NORTH);
f.add(b1, BorderLayout.WEST);
f.add(b2, BorderLayout.CENTER);
f.add(b3, BorderLayout.EAST);
f.add(l, BorderLayout.SOUTH);
f.setSize(500,500);
f.setLayout(null);
f.setVisible(true);
}
public static void main(String args[])
{
FlowExample GUI = new FlowExample();
GUI.launchFrame();
}
}
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|