The reason you have an extra icon, has nothing to do with the JDialog
. In you JOptionPane
, you're creating a new SelectionFrame()
response = JOptionPane.showConfirmDialog(new SelectionFrame("Selection"),
"Would you like to apply the policy attachment " + attachmentName + " to current instance (" + processInstance + ") of process " + processName + " ?", "Confirm",
JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);
You don't need to do that. You can just pass the SelectionFrame
to it. Here's a simple refactor of the constructor for SelectionDialog
. It works fine. Also, it looks the the setVisible
method is unnecessary. Just call dispose()
on it.
public SelectionDialog(final JFrame frame, boolean modal, String attachmentName, Long processInstance, String processName) {
super(frame, modal);
try {
UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
} catch (ClassNotFoundException | InstantiationException | IllegalAccessException | UnsupportedLookAndFeelException e) {
e.printStackTrace();
}
response = JOptionPane.showConfirmDialog(frame, "Would you like to apply the policy attachment " + attachmentName + " to current instance (" + processInstance + ") of process " + processName + " ?", "Confirm",
JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);
}
When you instantiate it, just do it like this
SelectionDialog dialog = new SelectionDialog(SelectionFrame.this, true,...)
Side Note
I honestly see no reason for the JDialog
at all if you're just going to use a JOptionPane
. You need to decide between one or the other. If you go with the JDialog
then don't use the JOptionPane
at all, and vice versa.
When you're creating a JDialog
, you're ultimately just creating a custom JOptionPane
, so when you use a JOptionPane
inside a JDialog
you're defeating the purpose of using one or the other.