G
Guest
Gast
Hallo,
Folgendes Problem beschäftigt mich gerade.
Ich möchte ein JDialog haben, die eine Combobox, Textfeld und ein Button enthält.
Die Werte sollte ich von aussen lesen und schreiben könnnen. Bisher habe ich es mit enem JPanel gemacht. So wie hier:
Ich möchte es aber als Dialog haben. Zb. in der Art:
Würde mich über Hilfe freuen.
Gruß
Folgendes Problem beschäftigt mich gerade.
Ich möchte ein JDialog haben, die eine Combobox, Textfeld und ein Button enthält.
Die Werte sollte ich von aussen lesen und schreiben könnnen. Bisher habe ich es mit enem JPanel gemacht. So wie hier:
Code:
public class URIPanel extends JPanel implements ActionListener {
private static final long serialVersionUID = 1L;
private JButton button;
private JComboBox comboBox;
private JTextField uri;
public void actionPerformed(ActionEvent arg0) {
}
/**
* This is the default constructor
*/
public URIPanel() {
setBorder(BorderFactory.createTitledBorder("Create URI"));
setLayout(new GridBagLayout());
GridBagConstraints gbc = new GridBagConstraints();
gbc.anchor = GridBagConstraints.LINE_START;
gbc.insets = new Insets(2, 2, 2, 2);
gbc.gridx = 0;
gbc.gridy = 0;
add(new JLabel("URI Identifier Code"),gbc);
this.comboBox = new JComboBox(URIType.IdentifierCodeList.toArray());
gbc.gridx = 1;
gbc.gridy = 0;
add(this.comboBox,gbc);
gbc.gridx = 0;
gbc.gridy = 2;
add(new JLabel("URI"),gbc);
gbc.gridx = 1;
gbc.gridy = 2;
this.uri = new JTextField(20);
add(this.uri,gbc);
this.uri.addKeyListener(new java.awt.event.KeyAdapter() {
public void keyTyped(java.awt.event.KeyEvent e) {
button.setEnabled(true);
}
});
this.button = new JButton("Ok");
this.button.setEnabled(false);
gbc.gridy = 4;
gbc.anchor = GridBagConstraints.SOUTH;
gbc.insets = new Insets(0, 0, 10, 0);
gbc.weighty = 1.0;
add(button, gbc);
}
public JButton getButton() {
return button;
}
public JComboBox getComboBox() {
return comboBox;
}
public JTextField getUri() {
return uri;
}
}
Ich möchte es aber als Dialog haben. Zb. in der Art:
Code:
String [] optionen = {"Element1", "Element2","Element3"};
int wahl = JOptionPane.showOptionDialog(new Frame(), "Option wählen","Dialogtitel",
JOptionPane.YES_NO_CANCEL_OPTION,JOptionPane.QUESTION_MESSAGE, null,
optionen, optionen[0]);
Würde mich über Hilfe freuen.
Gruß