|
what layout to use for vertical alignment?
Hello everyone! i d like your help on the following:
i d like the label, textfield and button (panel) to be appeared the one
under the other and not all in the same line.
what layout manager need to use?
Thanks!
panel=new JPanel();
panel2=new JPanel();
label=new JLabel("Choose a number from 1 to 10:");
enterField = new JTextField(8);
button=new JButton("Send");
enterField.setEnabled( false );
panel.setLayout(new FlowLayout(FlowLayout.CENTER));
panel.add(label);
panel.add(enterField);
panel.add(button);
displayArea = new JTextArea(10,25);
displayArea.setEnabled( false );
scroller = new JScrollPane( displayArea );
panel2.add(scroller);
Container container = getContentPane();
container.add( panel, BorderLayout.NORTH );
container.add( panel2, BorderLayout.SOUTH );
//setSize(400,250);
pack( );
setVisible( true );
|