Ensuring OK/Cancel visible when using complex JOptionPane

Hi all,

I am using a quite complex JOptionPane, but unfortunately there are occassions when the OK/Cancel buttons are not shown because the information I am displaying means that the buttons 'fall off' the bottom of the OptionPane. This isn't an issue if the user knows that there should be OK/Cancel buttons and can drag the size of the pane larger to gain access to them, but a new user can be presented with an option pane with no buttons and no idea how to proceed.

What I am hoping is that there is a simple way to ensure that the OK/Cancel buttons are always visible, is this possible?

The method below creates my option pane, but at the time it is created the height of the parametersPanel may not be final.

Thanks in advance for any help...

private JOptionPane getJOptionPane() {

if (jOptionPane == null) {

JPanel main = parent.getMainPanel();

parent.remove(main);

main.add(getTopLabel(),BorderLayout.NORTH);

main.add(parametersPanel,BorderLayout.CENTER);

jOptionPane = new JOptionPane(main,JOptionPane.PLAIN_MESSAGE,JOptionPane.OK_CANCEL_OPTION);

jOptionPane.addPropertyChangeListener(this);

}

return jOptionPane;

}

[1224 byte] By [pnicolsona] at [2007-10-3 2:50:08]
# 1
Um, just a wild stab in the dark here, but is there any chance that you can call pack() on the JOptionPane? That way it will always be the right size...
fireman.sparkeya at 2007-7-14 20:38:57 > top of Java-index,Desktop,Core GUI APIs...
# 2
Solved, looked through other posts and found pointer to Tech Tips - thanks to all..(msg now conains a scrollpane)
pnicolsona at 2007-7-14 20:38:57 > top of Java-index,Desktop,Core GUI APIs...