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

JMenuItem in WindowsLookAndFeel can't paint default icons

    XMLWordPrintable

Details

    • b115
    • windows_7
    • Verified

    Description

      FULL PRODUCT VERSION :
      java version " 1.7.0_17 "
      Java(TM) SE Runtime Environment (build 1.7.0_17-b02)
      Java HotSpot(TM) 64-Bit Server VM (build 23.7-b01, mixed mode)

      ADDITIONAL OS VERSION INFORMATION :
      Windows 7 - 64Bit
      Microsoft Windows [Version 6.1.7601]

      A DESCRIPTION OF THE PROBLEM :
      If you install the WindowsLookAndFeel and try to use a default Icon from the UIManager

      UIManager.getIcon( " InternalFrame.closeIcon " );

      with an JMenuItem an Exception is thrown.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Icon closeIcon=UIManager.getIcon( " InternalFrame.closeIcon " );
      JMenuItem item = new JMenuItem ( " Test " );
      item.setIcon(closeIcon);


      When painting the MenuItem
      Exception in thread " AWT-EventQueue-0 " java.lang.ClassCastException: javax.swing.JMenuItem cannot be cast to javax.swing.JButton
      at com.sun.java.swing.plaf.windows.WindowsIconFactory$FrameButtonIcon.paintIcon(WindowsIconFactory.java:177)



      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      MenuItem painted
      ACTUAL -
      Eception thrown

      REPRODUCIBILITY :
      This bug can be reproduced always.

      CUSTOMER SUBMITTED WORKAROUND :
      Just change the line
                      JButton b = (JButton)c;
      to
                      AbstractButton b = (AbstractButton )c;

      WindowsIconFactory.java at line 813

      Attachments

        Activity

          People

            leonidr Leonid Romanov (Inactive)
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: