javaswingjoptionpane

How to use `doClick()` on JOptionPane?


I have a custom JOptionPane with two buttons as follows:

AgreementPanel panel = new AgreementPanel(this); // JPanel with some JLabels and JTextFields
JOptionPane pane = new JOptionPane(panel, JOptionPane.NO_OPTION);
Object[] options = {"Accept", "Decline"};
option = pane.showOptionDialog(null, panel, "Agreement", JOptionPane.DEFAULT_OPTION, JOptionPane.PLAIN_MESSAGE, null, options, panel.txtMessage);

How can I use doClick() on Accept button? I need it somewhere in my program


Solution

  • I found the solution here: Closing a dialog created by JOptionPane.showOptionDialog() :)