Hallo,
ich habe ein Problem mit einem GridBagLayout: Meine Textfelder sind nicht erkennbar. Ich habe in der API nichts gefunden, womit ich meinem JTextField eine bestimmte Mindestgröße geben kann und auch sonst komm ich einfach nicht dahinter, was ich anders machen muss, damit die Felder breit genug sind, dass man mit ihnen was anfangen kann...
Der Code dazu:
Und so sieht das ganze aus (hab leider keine Soft hier um die Grafik auf den entscheidenden Teil zu reduzieren, hoffe 170kb sind nicht zuviel):
Was mache ich falsch?
ich habe ein Problem mit einem GridBagLayout: Meine Textfelder sind nicht erkennbar. Ich habe in der API nichts gefunden, womit ich meinem JTextField eine bestimmte Mindestgröße geben kann und auch sonst komm ich einfach nicht dahinter, was ich anders machen muss, damit die Felder breit genug sind, dass man mit ihnen was anfangen kann...
Der Code dazu:
Code:
GridBagLayout myGBL = new GridBagLayout();
JPanel panel = new JPanel(myGBL);
myGBL.addLayoutComponent(label0, new GridBagConstraints(0,0,7,1,1,1,GridBagConstraints.WEST,GridBagConstraints.BOTH,new Insets(0,0,0,0),0,0));
myGBL.addLayoutComponent(field0, new GridBagConstraints(8,0,3,1,1,1,GridBagConstraints.CENTER,GridBagConstraints.NONE,new Insets(0,0,0,0),0,0));
myGBL.addLayoutComponent(button0, new GridBagConstraints(11,0,2,1,1,1,GridBagConstraints.EAST,GridBagConstraints.NONE,new Insets(0,0,0,0),0,0));
myGBL.addLayoutComponent(label1, new GridBagConstraints(0,1,6,1,1,1,GridBagConstraints.WEST,GridBagConstraints.BOTH,new Insets(0,0,0,0),0,0));
myGBL.addLayoutComponent(label1a, new GridBagConstraints(7,1,1,1,1,1,GridBagConstraints.CENTER,GridBagConstraints.NONE,new Insets(0,0,0,0),0,0));
myGBL.addLayoutComponent(field1a, new GridBagConstraints(8,1,1,1,1,1,GridBagConstraints.CENTER,GridBagConstraints.NONE,new Insets(0,0,0,0),0,0));
myGBL.addLayoutComponent(label1b, new GridBagConstraints(9,1,1,1,1,1,GridBagConstraints.CENTER,GridBagConstraints.NONE,new Insets(0,0,0,0),0,0));
myGBL.addLayoutComponent(field1b, new GridBagConstraints(10,1,1,1,1,1,GridBagConstraints.CENTER,GridBagConstraints.NONE,new Insets(0,0,0,0),0,0));
myGBL.addLayoutComponent(button1, new GridBagConstraints(11,1,2,1,1,1,GridBagConstraints.EAST,GridBagConstraints.NONE,new Insets(0,0,0,0),0,0));
myGBL.addLayoutComponent(label2, new GridBagConstraints(0,2,9,1,1,1,GridBagConstraints.WEST,GridBagConstraints.BOTH,new Insets(0,0,0,0),0,0));
myGBL.addLayoutComponent(field2, new GridBagConstraints(10,2,1,1,1,1,GridBagConstraints.CENTER,GridBagConstraints.NONE,new Insets(0,0,0,0),0,0));
myGBL.addLayoutComponent(button2, new GridBagConstraints(11,2,2,1,1,1,GridBagConstraints.EAST,GridBagConstraints.NONE,new Insets(0,0,0,0),0,0));
myGBL.addLayoutComponent(label3, new GridBagConstraints(0,3,10,1,1,1,GridBagConstraints.WEST,GridBagConstraints.BOTH,new Insets(0,0,0,0),0,0));
myGBL.addLayoutComponent(button3, new GridBagConstraints(11,3,2,1,1,1,GridBagConstraints.EAST,GridBagConstraints.NONE,new Insets(0,0,0,0),0,0));
myGBL.addLayoutComponent(label4, new GridBagConstraints(0,4,10,1,1,1,GridBagConstraints.WEST,GridBagConstraints.BOTH,new Insets(0,0,0,0),0,0));
myGBL.addLayoutComponent(button4, new GridBagConstraints(11,4,2,1,1,1,GridBagConstraints.EAST,GridBagConstraints.NONE,new Insets(0,0,0,0),0,0));
myGBL.addLayoutComponent(label5, new GridBagConstraints(0,5,10,1,1,1,GridBagConstraints.WEST,GridBagConstraints.BOTH,new Insets(0,0,0,0),0,0));
myGBL.addLayoutComponent(button5, new GridBagConstraints(11,5,2,1,1,1,GridBagConstraints.EAST,GridBagConstraints.NONE,new Insets(0,0,0,0),0,0));
myGBL.addLayoutComponent(label6, new GridBagConstraints(0,6,10,1,1,1,GridBagConstraints.WEST,GridBagConstraints.BOTH,new Insets(0,0,0,0),0,0));
myGBL.addLayoutComponent(button6, new GridBagConstraints(11,6,2,1,1,1,GridBagConstraints.EAST,GridBagConstraints.NONE,new Insets(0,0,0,0),0,0));
myGBL.addLayoutComponent(buttonopen, new GridBagConstraints(0,8,4,1,1,1,GridBagConstraints.CENTER,GridBagConstraints.NONE,new Insets(0,0,0,0),0,0));
myGBL.addLayoutComponent(buttonsave, new GridBagConstraints(5,8,4,1,1,1,GridBagConstraints.CENTER,GridBagConstraints.NONE,new Insets(0,0,0,0),0,0));
myGBL.addLayoutComponent(buttonback, new GridBagConstraints(9,8,4,1,1,1,GridBagConstraints.CENTER,GridBagConstraints.NONE,new Insets(0,0,0,0),0,0));
panel.add(label0); panel.add(field0); panel.add(button0);
panel.add(label1); panel.add(label1a); panel.add(field1a); panel.add(label1b); panel.add(field1b); panel.add(button1);
panel.add(label2); panel.add(field2); panel.add(button2);
panel.add(label3); panel.add(button3);
panel.add(label4); panel.add(button4);
panel.add(label5); panel.add(button5);
panel.add(label6); panel.add(button6);
panel.add(buttonopen); panel.add(buttonsave); panel.add(buttonback);
frame.getContentPane().add(panel);
frame.setSize(800,600);
frame.setLocation(0,0);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
Und so sieht das ganze aus (hab leider keine Soft hier um die Grafik auf den entscheidenden Teil zu reduzieren, hoffe 170kb sind nicht zuviel):
Was mache ich falsch?