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

[macosx] JInternalFrame frame icon in wrong position on Mac L&F if icon is not ImageIcon

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P3
    • 9
    • 7, 8u66, 9
    • client-libs
    • b110
    • x86
    • os_x

    Description

      FULL PRODUCT VERSION :
      java version "1.8.0_66"
      Java(TM) SE Runtime Environment (build 1.8.0_66-b17)
      Java HotSpot(TM) 64-Bit Server VM (build 25.66-b17, mixed mode)

      ADDITIONAL OS VERSION INFORMATION :
      10.7.4

      A DESCRIPTION OF THE PROBLEM :
      Under the Mac Look&Feel, if an icon type other than an ImageIcon is used in JInternalFrame.setFrameIcon(), the icon will show up in the wrong position.

      This also happens under Java 7 and Java 9.


      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Compile and run code on a Mac.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Expect the icon (a green square) to be displayed to the left of the internal frame title text.
      ACTUAL -
      The icon is displayed lower than it should be and to the right of where it should be, covering part of the title text. The internal frame title bar also does not appear to have left enough space for the icon, as it would for an equivalent ImageIcon.

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      import java.awt.*;
      import javax.swing.*;

      public class JInternalFrameBug {

         public static void main(String[] args) {
            SwingUtilities.invokeLater(
                  new Runnable() {
                     public void run() {
                        try {
                           UIManager.setLookAndFeel("com.apple.laf.AquaLookAndFeel"); }
                        catch(Exception e) {
                           System.out.println("This is not a Mac.");
                           return;
                        }
                        JFrame f = new JFrame();
                        f.setSize(400, 400);
                        JDesktopPane dtp = new JDesktopPane();
                        JInternalFrame jif = new JInternalFrame();
                        jif.setTitle("Test");
                        jif.setFrameIcon(
                              new Icon() {
                                 public int getIconWidth() {
                                    return 16;
                                 }
                                 public int getIconHeight() {
                                    return 16;
                                 }
                                 public void paintIcon(Component c, Graphics g, int x, int y) {
                                    g.setColor(java.awt.Color.green);
                                    g.fillRect(x, y, 16, 16);
                                 }
                              });
                        jif.setSize(200, 200);
                        jif.setVisible(true);
                        dtp.add(jif);
                     
                        f.getContentPane().setLayout(new BorderLayout());
                        f.getContentPane().add(dtp, "Center");
                        f.setVisible(true);
                     }
                  });
         }
      }

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

      CUSTOMER SUBMITTED WORKAROUND :
      Only use ImageIcon for a JInternalFrame frame icon under Mac Look&Feel.

      Attachments

        Activity

          People

            aniyogi Avik Niyogi (Inactive)
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: