i am currently coding a produkt system and I am designing the interface. My Problem is, that the Interface is not in a colume.
I want it in one colume with my code code, also it would be good to add one more Button in the row of “suche nach waren”
Here is the code:
GroupLayout tLayout = new GroupLayout(mainFrame.getContentPane());
mainFrame.getContentPane().setLayout(tLayout);
tLayout.setAutoCreateGaps(true);
tLayout.setAutoCreateContainerGaps(true);
tLayout.setHorizontalGroup(tLayout.createSequentialGroup()
.addGroup(tLayout.createParallelGroup()
.addComponent(tLabel0))
.addGroup(tLayout.createParallelGroup()
.addComponent(tLabel1)
.addComponent(tLabel2)
.addComponent(tLabel3)
.addComponent(tLabel4))
.addGroup(tLayout.createParallelGroup()
.addComponent(tTextField1)
.addComponent(tTextField2)
.addComponent(tTextField3)
.addComponent(tCombo)
.addComponent(tButton1))
.addGroup(tLayout.createParallelGroup()
.addComponent(tTable))
);
tLayout.setVerticalGroup(tLayout.createSequentialGroup()
.addComponent(tLabel0)
.addGroup(tLayout.createParallelGroup()
.addComponent(tLabel1)
.addComponent(tTextField1))
.addGroup(tLayout.createParallelGroup()
.addComponent(tLabel2)
.addComponent(tTextField2))
.addGroup(tLayout.createParallelGroup()
.addComponent(tLabel3)
.addComponent(tTextField3))
.addGroup(tLayout.createParallelGroup()
.addComponent(tLabel4)
.addComponent(tCombo))
.addGroup(tLayout.createParallelGroup()
.addComponent(tButton1))
.addGroup(tLayout.createParallelGroup()
.addComponent(tTable)));
Whats wrong with my code?
I appreciate your answer!
PS.: I do not want to use a layout editor because its my first time and I want to learn about SWING!
PPS.:
|Geben sie bitte die Kriterien für die Suche an:
|Name: (textfield)
|Maximaler Preis: (textfield)
|Alter des Kunden:(textfield)
|Kategorie: (Combo)
| (Button)
|Table....
Everything is in the right place except the upper label and the table
GridBagLayout Example…
You really should put the
JTableinside a JScrollPane, it will take care of the header for you, but hay