I am using a JList in Java Swing, but when my Dialog opens, the List isn't shown.
private JList getJList() {
if (mylist == null) {
mylist = new JList();
mylist.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
mylist.setSize(new Dimension(154, 106));
model.addElement("test");
model.addElement("zwei");
mylist.setVisible(true);
}
return mylist;
}
The list is defined:
private JPanel getJContentPane() {
if (jContentPane == null) {
jContentPane = new JPanel();
jContentPane.setLayout(new BorderLayout());
jContentPane.add(getJList(), BorderLayout.CENTER);
}
return jContentPane;
}
It's a JContentPane (/Panel)
public fensterdrei(Frame owner) {
super(owner);
initialize();
}
the code calling getJContentPane()
:
private void initialize() {
this.setSize(300, 200);
this.setContentPane(getJContentPane());
this.setTitle("Auswahl");
}