problem in showMessageDialog method of JOptionPane
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
publicclass SwingCompextends JFrameimplements ActionListener{
public SwingComp()
{
JPanel p =new JPanel();
JButton b =new JButton("OK");
b.addActionListener(this);
p.add(b);
add(p);
pack();
setVisible(true);
}
publicstaticvoid main(String args[])
{
new SwingComp();
}
publicvoid actionPerformed(ActionEvent e)
{
{
JOptionPane.showMessageDialog( null,"Message","Title", JOptionPane.ERROR_MESSAGE );
}
//JDialog d = new JDialog();
//JButton b1 = new JButton("some");
//d.add(b1);
//d.pack();
//d.setVisible(true);
}
}
After running the above code is there any way in which I can add action listener to theok button that is displayed byJOptionPane.showMessageDialog( null, "Message", "Title", JOptionPane.ERROR_MESSAGE );dialog.
[2113 byte] By [
jaaya] at [2007-10-2 20:54:03]

I know that . I am asking this question because in the application that I am working on, this error dialog is invoked from a button in another dialog.
The problem that I am facing is , if i click ok button of JOptionPane then
the dialog that is behind this one also gets closed.
That is why I needed to add actionListener to the button so that i create a situation in which the dialog that invoked this error dialog doesnt get closed.
Regards
jaaya at 2007-7-13 23:38:29 >

> You'll need to customize the option pane in order to
> achieve what you want. The following link
> demonstrates customizing a JOptionPane dialog.
> You'll need to adapt the code for your purposes but
> it clearly demonstrates the technique.
>
> http://forum.java.sun.com/thread.jspa?forumID=513&thre
> adID=248471
Thanks for the information. Is there any other way by which the problem can be solved, I mean without customising...
jaaya at 2007-7-13 23:38:29 >
