ich habe einen dialog, bei dem ich jetzt noch einen button zum abbrechen zufügen wollte, der erscheint aber nicht.
hier der code:
kann mir jemand sagen, woran das liegt?
ich habe das problem allerdings noch in einem etwas größeren rahmen. dort befinden sich einige komponenten einfach außerhalb des dialogs (man sieht noch einen ganz kleinen teil vom ihnen, daher weiß ich das).
das ganze läuft noch auf java 1.4.2.
hier der code:
Code:
public class LoginDialog extends JDialog {
private GridBagLayout gbl = new GridBagLayout();
private GridBagConstraints gbc = new GridBagConstraints();
private JTextField tf_name = new JTextField();
private JPasswordField pf_pw = new JPasswordField();
private JButton btn_login = new JButton(ClientMainFrame.getLabel("log")),
btn_reg = new JButton(ClientMainFrame.getLabel("reg")),
btn_cancel = new JButton(ClientMainFrame.getLabel("cancel"));
private JLabel lbl_name = new JLabel(ClientMainFrame.getLabel("name")),
lbl_pw = new JLabel(ClientMainFrame.getLabel("pw"));
private CommandProcessor server ;
public LoginDialog ( final Frame frame,
final String title,
CommandProcessor s ) {
super(frame,title,true);
setSize(300,100);
setResizable(false);
setLocation(300,200);
addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
}
});
getContentPane().setLayout(gbl);
server = s;
//set layout components gbl and gbc to reference value
gbc.fill = GridBagConstraints.BOTH;
gbc.gridx = GridBagConstraints.RELATIVE;
gbc.gridy = GridBagConstraints.RELATIVE;
gbc.weightx = 1.0;
gbc.weighty = 1.0;
gbc.gridwidth = GridBagConstraints.RELATIVE;
gbc.gridheight = 1;
//configure components
gbl.setConstraints(lbl_name,gbc);
getContentPane().add(lbl_name);
gbc.gridwidth = GridBagConstraints.REMAINDER;
gbc.weightx = 3.0;
gbl.setConstraints(tf_name,gbc);
getContentPane().add(tf_name);
gbc.weightx = 1.0;
gbc.gridwidth = GridBagConstraints.RELATIVE;
gbc.weightx = 1.0;
gbl.setConstraints(lbl_pw,gbc);
getContentPane().add(lbl_pw);
gbc.gridwidth = GridBagConstraints.REMAINDER;
gbc.weightx = 3.0;
gbl.setConstraints(pf_pw,gbc);
getContentPane().add(pf_pw);
gbc.gridwidth = GridBagConstraints.RELATIVE;
gbc.weightx = 1.0;
gbl.setConstraints(btn_login,gbc);
getContentPane().add(btn_login);
gbl.setConstraints(btn_reg,gbc);
getContentPane().add(btn_reg);
gbc.gridwidth = GridBagConstraints.REMAINDER;
gbl.setConstraints(btn_cancel,gbc);
getContentPane().add(btn_cancel);
}
}
kann mir jemand sagen, woran das liegt?
ich habe das problem allerdings noch in einem etwas größeren rahmen. dort befinden sich einige komponenten einfach außerhalb des dialogs (man sieht noch einen ganz kleinen teil vom ihnen, daher weiß ich das).
das ganze läuft noch auf java 1.4.2.