buri
asked on
JOptionPane position in a JDesktopPane within a JScrollPane
Hi,
I have implemented a scrollable workspace which is a JDesktopPane inside of a JScrollPane. When I use JOptionPane.showInternalXX XX() 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.createInternal Frame()). 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.
I have implemented a scrollable workspace which is a JDesktopPane inside of a JScrollPane. When I use JOptionPane.showInternalXX
I have already tried overriding the createInternalFrame() method with one of my own, but modality requires package-private calls (JInternalFrame.startModal
Is there a clean way to make an internal option pane centered on an arbitrary unit, rather than the highest JDesktopPane?
Thanks in advance.
You need to create your own option pane 'manually'.
ASKER
Please elaborate on this statement.
I have tried creating a JOptionPane and placing it inside of a JInternalFrame, but this does not accurately mimick the behaviour of the modal JDialog. The JOptionPane's internal methods accomplisht his by calling package-private methods which I cannot access without placing my code in the javax.swing package.
Thanks.
BU
I have tried creating a JOptionPane and placing it inside of a JInternalFrame, but this does not accurately mimick the behaviour of the modal JDialog. The JOptionPane's internal methods accomplisht his by calling package-private methods which I cannot access without placing my code in the javax.swing package.
Thanks.
BU
Create an JOPtionPane object directly via one of it's ctor. Then create your JDialog using the createDialog() method, and place this dialog where you require it.
JOptionPane pane = new JOptionPane(.....
JDialog dialog = pane.createDialog(viewport , "Title");
JOptionPane pane = new JOptionPane(.....
JDialog dialog = pane.createDialog(viewport
ASKER
There is no problem with the JDialog -- it's the INTERNAL variety that I need to circumvent. All of my external option panes function correctly.
Thanks.
BU
Thanks.
BU
Sorry that should have said createInternalFrame(...
What do you pass as the frame parent?
Have you tried using the viewport?
Have you tried using the viewport?
ASKER
The parent must be a child of the desktop pane within the viewport, otherwise JOptionPane.createInternal Frame() will exit on a NPE at line 1118, where it tries to center on the desktop pane ancestor.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
This seems to work appropriately. Thanks for your help!
No worries :-)
http://www.objects.com.au/staff/mick
Brainch MVP for Java 1
http://www.brainbench.com
http://www.objects.com.au/staff/mick
Brainch MVP for Java 1
http://www.brainbench.com