Re: Stupid dialog closing question
Ok. After a day of fiddling and reading tutorials, I came up with the
following solution. I wrapped the lot into it's own class with it's own
ActionListener:
public class FooBar extends JPanel implements ActionListener {
private JDialog dialog;
public FooBar (){
JPanel panel = new JPanel();
panel.setLayout(new BorderLayout());
JButton fooButton = new JButton("Foo!");
fooButton.addActionListener(this);
JButton barButton = new JButton("Bar!");
JOptionPane pane = new JOptionPane();
pane.setInitialValue(fooButton);
pane.setMessage("Foo & Bar");
pane.setMessageType(JOptionPane.PLAIN_MESSAGE);
pane.setOptions(new JButton[] { fooButton, barButton} );
dialog = pane.createDialog(null, "FooBar");
dialog.setVisible(true);
}
public void actionPerformed(ActionEvent e) {
System.err.println("Button Foo!");
dialog.setVisible(false);
}
Is this the way to make windows auto close after pressing a button?
Koos
--
43rd Law of Computing: Anything that can go wr
fortune: Segmentation violation -- Core dumped