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

JMenuItem Icon not displayed in JMenuBar

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P3 P3
    • None
    • 6
    • client-libs

      FULL PRODUCT VERSION :
      java version "1.6.0-rc"
      Java(TM) SE Runtime Environment (build 1.6.0-rc-b96)
      Java HotSpot(TM) Client VM (build 1.6.0-rc-b96, mixed mode, sharing)

      ADDITIONAL OS VERSION INFORMATION :
      Microsoft Windows XP [Version 5.1.2600]

      A DESCRIPTION OF THE PROBLEM :
      I have a JMenuItem with a Icon.
      This JMenuItem ist directly added to a JMenuBar.
      The Icon is not displayed (just a grey rectangle).

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Here is a simple test-file to reproduce the bug.
      You only must change the path to the ImageIcon (i can not attach the
      icon, you must use your own ;))

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


      public class JMenuIconBug {


          private static void createAndShowGUI() {
              JFrame frame = new JFrame("TEST");
              frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              frame.setSize(300,100);
              JMenuItem jmi_TTCLogo = new JMenuItem(new
      ImageIcon("images/1.png")); //$NON-NLS-1$
              jmi_TTCLogo.setHorizontalAlignment(SwingConstants.RIGHT);
              jmi_TTCLogo.setRolloverEnabled(false);
              jmi_TTCLogo.setText(" "); //$NON-NLS-1$
              JMenuBar jmb = new JMenuBar();
              jmb.add(jmi_TTCLogo);
              frame.setJMenuBar(jmb);
              frame.setVisible(true);
          }

          public static void main(String[] args) {
              SwingUtilities.invokeLater(new Runnable() {
                  public void run() {
                      createAndShowGUI();
                  }
              });
          }

      }

      ---------- END SOURCE ----------
      REPRODUCIBILITY :
      This bug can be reproduced always.

      Release Regression From : 5.0u8
      The above release value was the last known release where this
      bug was not reproducible. Since then there has been a regression.

            mlapshin Mikhail Lapshin (Inactive)
            ndcosta Nelson Dcosta (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: