Hallo,
ich habe ein Problem mit JScrollPane. Hier mal mein Code:
Woran könnte es liegen, dass die ScollPane bei mir nicht funktioniert? Wäre über eine Hilfe sehr dankbar...
ich habe ein Problem mit JScrollPane. Hier mal mein Code:
Java:
public class TestUI extends JFrame {
private static final long serialVersionUID = 5198860553212716246L;
private static JPanel sublayer01;
private static JButton[] jb;
public TestUI() {
setSize(300, 200);
setDefaultCloseOperation(EXIT_ON_CLOSE);
Container content = getContentPane();
content.setLayout(new GridLayout());
JPanel layer01 = new JPanel();
layer01.setLayout(new GridLayout(1, 1));
sublayer01 = new JPanel();
sublayer01.setLayout(null);
anlegen();
JScrollPane scroll = new JScrollPane(sublayer01,
JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
layer01.add(scroll);
content.add(layer01);
setVisible(true);
}
private void anlegen() {
jb = new JButton[10];
int beginn = 20;
for (int i = 0; i < jb.length; i++) {
JButton jb1 = new JButton("Button");
jb1.setBounds(130, beginn, 100, 20);
jb[i] = jb1;
beginn = beginn + 25;
sublayer01.add(jb[i]);
}
}
public static void main(String[] args) {
new TestUI();
}
}
Woran könnte es liegen, dass die ScollPane bei mir nicht funktioniert? Wäre über eine Hilfe sehr dankbar...