Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8152961

Windows 10 Look and Feel HiDPI Title Buttons Too Big on JInternalFrame

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P4
    • Resolution: Duplicate
    • Affects Version/s: 8u77
    • Fix Version/s: None
    • Component/s: client-libs

      Description

      FULL PRODUCT VERSION :


      ADDITIONAL OS VERSION INFORMATION :
      Microsoft Windows [Version 10.0.10586]
      (c) 2015 Microsoft Corporation. All rights reserved.

      C:\Users\Owner>ver

      Microsoft Windows [Version 10.0.10586]

      C:\Users\Owner>java -ver
      Unrecognized option: -ver
      Error: Could not create the Java Virtual Machine.
      Error: A fatal exception has occurred. Program will exit.

      C:\Users\Owner>

      EXTRA RELEVANT SYSTEM CONFIGURATION :
      2K monitor with 2560x1440p resolution. Specific monitor is the Asus PB258Q monitor. DPI scaling settings in Windows slider is set to 144%.
      http://www.newegg.com/Product/Product.aspx?Item=N82E16824236453

      A DESCRIPTION OF THE PROBLEM :
      The close/min/max buttons on a JInternalFrame are oversized on WIndows 10 when using a HiDPI monitor.
      http://imgur.com/kEsbJzp

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      1) Create a JDesktopPane
      2) Create several JInternalFrames with close/min/max buttons.
      3) Set the native look and feel and show the frames
      4) Observe the over sized close/min/max buttons


      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      /*
       * Copyright (c) 1995, 2008, Oracle and/or its affiliates. All rights reserved.
       *
       * Redistribution and use in source and binary forms, with or without
       * modification, are permitted provided that the following conditions
       * are met:
       *
       * - Redistributions of source code must retain the above copyright
       * notice, this list of conditions and the following disclaimer.
       *
       * - Redistributions in binary form must reproduce the above copyright
       * notice, this list of conditions and the following disclaimer in the
       * documentation and/or other materials provided with the distribution.
       *
       * - Neither the name of Oracle or the names of its
       * contributors may be used to endorse or promote products derived
       * from this software without specific prior written permission.
       *
       * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
       * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
       * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
       * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
       * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
       * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
       * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
       * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
       * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
       * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
       * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
       */

      package test;

      import javax.swing.JInternalFrame;
      import javax.swing.JDesktopPane;
      import javax.swing.JMenu;
      import javax.swing.JMenuItem;
      import javax.swing.JMenuBar;
      import javax.swing.JFrame;
      import javax.swing.KeyStroke;
      import javax.swing.UIManager;
      import javax.swing.UnsupportedLookAndFeelException;

      import java.awt.event.*;
      import java.awt.*;

      /*
       * InternalFrameDemo.java requires:
       * MyInternalFrame.java
       */
      public class JInternalFrameWin10HiDPI extends JFrame
                                     implements ActionListener {
          JDesktopPane desktop;

          public JInternalFrameWin10HiDPI() {
              super("InternalFrameDemo");

              //Make the big window be indented 50 pixels from each edge
              //of the screen.
              int inset = 50;
              Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
              setBounds(inset, inset,
                        screenSize.width/2 - inset*2,
                        screenSize.height/2 - inset*2);

              //Set up the GUI.
              desktop = new JDesktopPane(); //a specialized layered pane
              createFrame(); //create first "window"
              setContentPane(desktop);
              setJMenuBar(createMenuBar());

              //Make dragging a little faster but perhaps uglier.
              desktop.setDragMode(JDesktopPane.OUTLINE_DRAG_MODE);
          }

          protected JMenuBar createMenuBar() {
              JMenuBar menuBar = new JMenuBar();

              //Set up the lone menu.
              JMenu menu = new JMenu("Document");
              menu.setMnemonic(KeyEvent.VK_D);
              menuBar.add(menu);

              //Set up the first menu item.
              JMenuItem menuItem = new JMenuItem("New");
              menuItem.setMnemonic(KeyEvent.VK_N);
              menuItem.setAccelerator(KeyStroke.getKeyStroke(
                      KeyEvent.VK_N, ActionEvent.ALT_MASK));
              menuItem.setActionCommand("new");
              menuItem.addActionListener(this);
              menu.add(menuItem);

              //Set up the second menu item.
              menuItem = new JMenuItem("Quit");
              menuItem.setMnemonic(KeyEvent.VK_Q);
              menuItem.setAccelerator(KeyStroke.getKeyStroke(
                      KeyEvent.VK_Q, ActionEvent.ALT_MASK));
              menuItem.setActionCommand("quit");
              menuItem.addActionListener(this);
              menu.add(menuItem);

              return menuBar;
          }

          //React to menu selections.
          public void actionPerformed(ActionEvent e) {
              if ("new".equals(e.getActionCommand())) { //new
                  createFrame();
              } else { //quit
                  quit();
              }
          }

          //Create a new internal frame.
          protected void createFrame() {
              JInternalFrame frame = new JInternalFrame("Frame", true, true, true, true);
              frame.setSize(200, 200);
              frame.setVisible(true); //necessary as of 1.3
              desktop.add(frame);
              try {
                  frame.setSelected(true);
              } catch (java.beans.PropertyVetoException e) {}
          }

          //Quit the application.
          protected void quit() {
              System.exit(0);
          }

          /**
           * Create the GUI and show it. For thread safety,
           * this method should be invoked from the
           * event-dispatching thread.
           */
          private static void createAndShowGUI() {
              //Make sure we have nice window decorations.
              JFrame.setDefaultLookAndFeelDecorated(true);

              //Create and set up the window.
              JInternalFrameWin10HiDPI frame = new JInternalFrameWin10HiDPI();
              frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

              //Display the window.
              frame.setVisible(true);
          }

          public static void main(String[] args) {
              // Set the Windows Look and Feel
              try {
                UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
              } catch (ClassNotFoundException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
              } catch (InstantiationException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
              } catch (IllegalAccessException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
              } catch (UnsupportedLookAndFeelException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
              }

              //Schedule a job for the event-dispatching thread:
              //creating and showing this application's GUI.
              javax.swing.SwingUtilities.invokeLater(new Runnable() {
                  public void run() {
                      createAndShowGUI();
                  }
              });
          }
      }

      ---------- END SOURCE ----------

      SUPPORT :
      YES

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              alexsch Alexandr Scherbatiy
              Reporter:
              webbuggrp Webbug Group
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: