Hi everybody,
nomatter how long I fiddle with
java, I always end struggling with the gui!
consider following stuff: I expext glue and gets a monstruous large JTextField. What have i overlooked now?
Thanks
import java.awt.*;
import javax.swing.*;
class
Test extends JFrame{
Test(){
super();
String[] names = {"I","LIKE"};
String[] names2 = {"J","A","V","A","R","A","N","C","H"};
JList jList1 = new JList(names);
JList jList2 = new JList(names2);
JLabel jLabel1 = new JLabel("K.Sierra for pope!");
JButton jButton = new JButton("OK");
JTextField jTextField = new JTextField(12);
JLabel display = new JLabel("but swing? ");
JPanel box = new JPanel();
box.setLayout(new BoxLayout(box,BoxLayout.X_AXIS));
box.add(new JScrollPane(jList1));
box.add(new JScrollPane(jList2));
Box mainPanel = new Box(BoxLayout.Y_AXIS);
mainPanel.add(jLabel1);
mainPanel.add(box);
mainPanel.add(jTextField);
//I expet some really large space here
mainPanel.add(Box.createGlue());
//and now continue
mainPanel.add(jButton);
mainPanel.add(display);
getContentPane().add(mainPanel,BorderLayout.CENTER);
setSize(800,600);
setVisible(true);
}
public static void main(String[] args){
new Test();
}
}