JOptionPane position in a JDesktopPane within a JScrollPane
Posted on 2002-05-27
I have implemented a scrollable workspace which is a JDesktopPane inside of a JScrollPane. When I use JOptionPane.showInternalXXXX() the option pane appears centered over the desktop pane, which may or may not be visible in the viewport of the scroll pane (the code that actually does this is in JOptionPane.createInternalFrame()). I would prefer to have the option pane appear centered over the visible viewport rather than the entire desktop pane but the modal nature of the option panes prevents me from repositioning anything after creation.
I have already tried overriding the createInternalFrame() method with one of my own, but modality requires package-private calls (JInternalFrame.startModal()) which cannot be accessed from my new method.
Is there a clean way to make an internal option pane centered on an arbitrary unit, rather than the highest JDesktopPane?
Thanks in advance.