JDK-8169691 : GraphicsEnvironment doesn't reload ScreenDevices on runtime with Java Web Start
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 6u45,7,8,9
  • Priority: P3
  • Status: Closed
  • Resolution: Cannot Reproduce
  • OS: windows_7
  • CPU: x86_64
  • Submitted: 2016-11-14
  • Updated: 2018-11-26
  • Resolved: 2017-05-23
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 10
10Resolved
Related Reports
Relates :  
Description
FULL PRODUCT VERSION :
java version "1.8.0_111"
Java(TM) SE Runtime Environment (build 1.8.0_111-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.111-b14, mixed mode)

ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows [Version 6.1.7601]

A DESCRIPTION OF THE PROBLEM :
The screen devices in GraphicsEnvironment seems to be not refresh on runtime by running your application with JavaWebstart. This lead into positioning problems if you drag the frame to the second screen device. For example JOptionePane dialogs displayed not in the middle of the frame. The dialog appears on the other screen. Same with drop-down-popup of a combobox, drop-down appears on other screen device.

Run the same application direct with the java command all works as expected.

REGRESSION.  Last worked in version 6u45

ADDITIONAL REGRESSION INFORMATION: 
JRE-Version 1.6.0_45-b06 Java HotSpot(TM) 64-Bit Server VM

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
- You need two screen devices for example a laptop and an external screen
- Change os settings to use only one screen device
- Start my test-example with javaws (make a jar of the test class and use the added jnlp-file to run javaws on localhost)
- Click button "Show JOptionPane", standard output shows
-- getScreenDevices: 1
-- getDevice().getIDstring():\Display0
-- OptionPane dialog appears in the middle of the frame
-- Close OptionPane
- Don't stop the test application
- Change os settings to extended desktop both screen devices now active
- Click the button "Show JOptionPane" again, standard output shows
-- getScreenDevices: 1
-- getDevice().getIDstring():\Display0
-- OptionPane dialog appears in the middle of the frame
-- Close OptionPane
- Move frame to second screen device
- Click button "Show JOptionPane" again, standard output shows
-- getScreenDevices: 1
-- getDevice().getIDstring():\Display0
-- OptionPane dialog appears on other screen device
-- Close OptionPane
- Collapse the combobox
-- combobox drop-down appears on other screen devices

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
After adding second screen device on runtime the optionpane behavior and the combobox drop-down should work as before.
ACTUAL -
- Two screen devices are active and the application have been moved to display1 but output shows:
- getScreenDevices: 1
- getDevice().getIDstring():\Display0

and OptionPane dialog and combobox-drop-down appears on the other screen device

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
public class ScreenLocationTest extends JFrame
{

   public ScreenLocationTest()
   {
      super("Test");
      setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

      this.getContentPane().add(this.createUI(), BorderLayout.CENTER);

      pack();
      setVisible(true);
   }

   private JPanel createUI()
   {
      JPanel panel = new JPanel(new FlowLayout());

      JButton button = new JButton("Show JOptionPane");
      button.addActionListener(new ActionListener()
      {

         @Override
         public void actionPerformed(ActionEvent e)
         {
            System.out.println("GraphicsEnvironment.getLocalGraphicsEnvironment().getScreenDevices().length:"
                  + GraphicsEnvironment.getLocalGraphicsEnvironment().getScreenDevices().length);

            System.out.println("ScreenLocationTest.this.getGraphicsConfiguration().getDevice().getIDstring():" + ScreenLocationTest.this.getGraphicsConfiguration().getDevice().getIDstring());
            
            JOptionPane.showConfirmDialog(ScreenLocationTest.this, "Message", "Title", JOptionPane.YES_NO_OPTION);

         }
      });
      panel.add(button);
      
      JComboBox combobox = new JComboBox(new Object[]{"Item1","Item2","Item3"});
      panel.add(combobox);
      
      return panel;
   }

   public static void main(String[] args)
   {
      new ScreenLocationTest();
   }
}

<?xml version="1.0" encoding="utf-8"?>
<jnlp spec="1.0+" 
      codebase="file:///E:/temp/screen-test/"
      href="test.jnlp">
  <information>
    <title>Test-Screen</title>
  </information>
<update check="always"/>
<resources>
<java version="1.6+" java-vm-args="-Xms24m -Xmx1024m"/>
<jar href="screentest.jar"/>
</resources>
<application-desc main-class="tup.jrw.tools.testlabor.ScreenLocationTest">
</application-desc>
</jnlp>
---------- END SOURCE ----------

CUSTOMER SUBMITTED WORKAROUND :
Restart the application after added an additional screen device.


Comments
Tested with b162 on windows7 and not able to reproduce.
23-05-2017

I am not able to reproduce it with standalone jdk 8GA either in my above mentioned environment and steps. when i tried to run "javaws test.jnlp", it gives "Application blocked by java security", so cannot run in javaws mode. Since it is mentioned that it is seen from 6u45, it should affect 8GA javaws execution.
26-04-2017

Does it affect 8 GA?
25-04-2017

I tried on windows 7 in dual screen environment using standalone java (jdk9) and I am not able to reproduce this. Steps followed are: 1. Change os settings to use only one screen device 2. Click button "Show JOptionPane", standard output shows GraphicsEnvironment.getLocalGraphicsEnvironment().getScreenDevices().length:1 ScreenLocationTest.this.getGraphicsConfiguration().getDevice().getIDstring():\Display0 3. OptionPane dialog appears in the start of the frame 4. Close OptionPane 5. Don't stop the test application 6. Change os settings to extended desktop both screen devices now active 7. Click the button "Show JOptionPane" again, standard output shows GraphicsEnvironment.getLocalGraphicsEnvironment().getScreenDevices().length:2 ScreenLocationTest.this.getGraphicsConfiguration().getDevice().getIDstring():\Display0 8. OptionPane dialog appears in the start of the frame 9. Close OptionPane 10. Move frame to second screen device 11. Click button "Show JOptionPane" again, standard output shows GraphicsEnvironment.getLocalGraphicsEnvironment().getScreenDevices().length:2 ScreenLocationTest.this.getGraphicsConfiguration().getDevice().getIDstring():\Display1 12. OptionPane dialog appears on 2nd screen device, which I guess is correct.
25-04-2017

I can reproduce the same problem (with JDK9 on My MacOSX) with this app run as a stand alone java app. The app reports 2 screens - If I move frame to second screen, then show JOptionPane, after that dropdown menu shows in different places (I don't even have to disconnect and reconnect second screen) I see the same behavior running "Java ScreenLocationTest" as when run with javaws, so Transferring to swing team. If I do disconnect second screen - printout shows GraphicsEnvironment.getLocalGraphicsEnvironment().getScreenDevices().length:1 and frame moved to first screen. When I reconnect second screen, frame moves back to second screen and printout says: GraphicsEnvironment.getLocalGraphicsEnvironment().getScreenDevices().length:2 dropdown is only in wrong place when on second screen, may be related to second screen being much bigger. anyway, as I said - this is the same behavior in javaws as stand alone app - so moving to client-libs/javax.swing. (note - I cannot reproduce the problem where the app displays one screen device (when there are two) , or where popup is on wrong screen - so there may be a further problem specific to windows - which I don't have an environment to reproduce).
19-04-2017

Submitter responded back confirming issue is reproducible with 8u102. Checked further and found reproducible in JDK 8u111, 8u122 ea b and 9 ea b144. 8u101: FAIL 8u102: FAIL 8u111: FAIL 8u122 ea b08: FAIL 9 ea b144: FAIL To reproduce, run the linked test case in a dual screen environment. Instructions: ======================================== Note: You need two screen devices for example a laptop and an external screen - Change os settings to use only one screen device - Start test.jnlp with javaws - Click button "Show JOptionPane", standard output shows -- getScreenDevices: 1 -- getDevice().getIDstring():\Display0 -- OptionPane dialog appears in the middle of the frame -- Close OptionPane - Don't stop the test application - Change os settings to extended desktop both screen devices now active - Click the button "Show JOptionPane" again, standard output shows -- getScreenDevices: 1 -- getDevice().getIDstring():\Display0 -- OptionPane dialog appears in the middle of the frame -- Close OptionPane - Move frame to second screen device - Click button "Show JOptionPane" again, standard output shows -- getScreenDevices: 1 -- getDevice().getIDstring():\Display0 -- OptionPane dialog appears on other screen device -- Close OptionPane - Collapse the combobox -- combobox drop-down appears on other screen devices ================================================== This seems related to JDK-8162507.
16-11-2016

The description refer to issue with older JDK version 6u45. Written back to the submitter to reconfirm if the issue exists with current version 8u111.
15-11-2016