Hallo !
Habe eine Frage zum Layout.
bin mir gerade am basteln einer grafishen Oberfläche. Nur leider will die nicht so wie ich will :?:
Screenshot
Und zwar geht es um die Größenverhältnisse zwischen der Textbox und dem Searchbutton, wokann ich einstellen dass diese beiden die gleiche Höhe haben.
Code für das Gridbaglayout
Bin für Hilfe dankbar
Grüße
ava98
Habe eine Frage zum Layout.
bin mir gerade am basteln einer grafishen Oberfläche. Nur leider will die nicht so wie ich will :?:
Screenshot
Und zwar geht es um die Größenverhältnisse zwischen der Textbox und dem Searchbutton, wokann ich einstellen dass diese beiden die gleiche Höhe haben.
Code für das Gridbaglayout
Code:
GridBagLayout gridbag = new GridBagLayout();
GridBagConstraints constraints = new GridBagConstraints();
JPanel panel = new JPanel();
panel.setLayout(gridbag);
// Suchbegriff Label
buildConstraints(constraints, 0, 0, 1, 1, 10, 40);
constraints.fill = GridBagConstraints.BOTH;
constraints.anchor = GridBagConstraints.EAST;
JLabel label1 = new JLabel("Suchbegriff:", JLabel.LEFT);
gridbag.setConstraints(label1, constraints);
panel.add(label1);
// Name text field
buildConstraints(constraints, 0, 1, 1, 1, 10, 10);
constraints.fill = GridBagConstraints.HORIZONTAL;
JTextField tfname1 = new JTextField();
gridbag.setConstraints(tfname1, constraints);
panel.add(tfname1);
// Search Button
buildConstraints(constraints, 1, 1, 1, 1, 0, 0);
constraints.fill = GridBagConstraints.BOTH;
JButton search = new JButton("Search");
gridbag.setConstraints(search, constraints);
panel.add(search);
Bin für Hilfe dankbar
Grüße
ava98