Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Newbie Question

 
tan kian
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i've just learned java GUI for a few days, so heres a pretty basic question: all i wanna do is to make this interface below.

-------------------------------------
Buttons here |
------------------------------------|
|
Panel for displaying other things |
|
|
-------------------------------------

but this is the interface i keep getting:

----------------------------------
| |
buttons here | display here |
| |
| |
| |
| |
| |
| |
----------------------------------

heres my code. Can someone help?

JButton yes = new JButton("Yes");
JButton no = new JButton("No");
JButton maybe = new JButton("Maybe");

public Tgui()
{
JPanel pn = new JPanel();
JPanel display = new JPanel();

Container container = getContentPane();
container.setLayout(new GridLayout(9,1));

Container displayer = getContentPane();
displayer.setLayout(new GridLayout(1,1));

pn.add(yes);
pn.add(no);
pn.add(maybe);

container.add(pn);
display.setBackground(Color.white);
displayer.add(display);
setTitle("Test");
}

public static void main(String [] args)
{
Tgui t = new Tgui();

t.setSize(640,420);
t.setLocation(30,30);
t.setVisible(true);
t.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
try this

 
tan kian
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i've tried it, but its no use =(
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic