Hallo,
ich möchte einfach einige Labels anordnen. Hier ist mein erfolgloser Versuch:
Die Constraints haben keine Auswirkung. Woran liegt das?
Viele Grüße
Michael
ich möchte einfach einige Labels anordnen. Hier ist mein erfolgloser Versuch:
Java:
package org.jis.view.dialog;
import java.awt.GraphicsConfiguration;
import java.awt.GraphicsDevice;
import java.awt.GraphicsEnvironment;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.HeadlessException;
import java.awt.Rectangle;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.JSlider;
import javax.swing.JTextField;
public class MosaiqueDialog extends JDialog {
/**
*
*/
private static final long serialVersionUID = 1L;
JLabel l_input;
JLabel l_output;
JTextField t_input = new JTextField();
JTextField t_output = new JTextField();
JSlider js = new JSlider();
JButton start = new JButton();
JButton input = new JButton();
JButton output = new JButton();
public MosaiqueDialog(Main m) throws HeadlessException {
super(m, m.mes.getString("Menu.17"), true);
GridBagLayout gridbag = new GridBagLayout();
GridBagConstraints constraints = new GridBagConstraints();
constraints.fill = GridBagConstraints.NONE;
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsDevice[] gs = ge.getScreenDevices();
GraphicsDevice gd = gs[0];
GraphicsConfiguration gc = gd.getDefaultConfiguration();
Rectangle bounds = gc.getBounds();
setLocation((bounds.width / 2) - 275, (bounds.height / 2) - 135);
setSize(650, 470);
this.l_input = new JLabel(m.mes.getString("OptionsEdit.21"));
this.l_output = new JLabel(m.mes.getString("OptionsEdit.0"));
setConstraints(constraints, 0, 0, 300, 20, 10, 10);
gridbag.setConstraints(l_input, constraints);
this.add(l_input);
setConstraints(constraints, 0, 30, 300, 20, 10, 10);
gridbag.setConstraints(l_output, constraints);
this.add(l_output);
addWindowListener(new CloseListner());
// this.pack();
setVisible(true);
}
private void setConstraints(GridBagConstraints gbc, int gx, int gy, int gw, int gh, int wx, int wy)
{
gbc.gridx = gx;
gbc.gridy = gy;
gbc.gridwidth = gw;
gbc.gridheight = gh;
gbc.weightx = wx;
gbc.weighty = wy;
}
}
Die Constraints haben keine Auswirkung. Woran liegt das?
Viele Grüße
Michael