It is currently 08 Sep 2025, 11:52
   
Text Size

Pass JOptionPane.getRootFrame() to JOptionPane.show*()

Post MTG Forge Related Programming Questions Here

Moderators: timmermac, Blacksmith, KrazyTheFox, Agetian, friarsol, CCGHQ Admins

Pass JOptionPane.getRootFrame() to JOptionPane.show*()

Postby drdev » 08 Oct 2013, 00:55

I just committed a fix so all the JOptionPane dialogs now properly appear centered over and on top of the main Forge window (r23436). Previously, many of those dialogs would appear centered on your main monitor even if Forge was elsewhere, such as a second monitor.

To maintain this fix for future dialogs, please be sure to pass JOptionPane.getRootFrame() as the first parameter to all JOptionPane.show*() functions instead of null (in cases where a more specific parent doesn't exist).

Also be sure any custom JOptionPane instances (see CardListView and ListChooser classes) pass JOptionPane.getRootFrame() as the first parameter to optionPane.createDialog(). Previously these places were just passing optionPane.getParent(), which was always null because none had been set.

Also use the new FDialog class as the base class for any other custom dialogs not created using optionPane.createDialog() (see DeckImport class). That class will wrap the logic necessary to have the main window automatically parent it, in addition to ensuring it appears centered over it by default.

Eventually I hope to support skinning these dialogs to make them look nicer, at which point the API may change. I'll let you know if and when this occurs.

EDIT: The issue where Full Screen Forge minimizes when a JOptionPane dialog is opened has now been fixed (r23437). In the process, I've also fixed it so if you have multiple monitors with Forge open Full Screen on one, it doesn't minimize when activating an application on the other monitor.
drdev
Programmer
 
Posts: 1958
Joined: 27 Jul 2013, 02:07
Has thanked: 189 times
Been thanked: 565 times

Return to Developer's Corner

Who is online

Users browsing this forum: Google Adsense [Bot] and 59 guests

Main Menu

User Menu

Our Partners


Who is online

In total there are 60 users online :: 1 registered, 0 hidden and 59 guests (based on users active over the past 10 minutes)
Most users ever online was 7303 on 15 Jul 2025, 20:46

Users browsing this forum: Google Adsense [Bot] and 59 guests

Login Form