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

setPressedIcon does not work unless setIcon is used

    XMLWordPrintable

    Details

    • Type: Enhancement
    • Status: Open
    • Priority: P5
    • Resolution: Unresolved
    • Affects Version/s: 6
    • Fix Version/s: tbd
    • Component/s: client-libs

      Description

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


      ADDITIONAL OS VERSION INFORMATION :
      Linux CGHVH01 2.6.18.8-0.5-default #1 SMP Fri Jun 22 12:17:53 UTC 2007 i686 i686 i386 GNU/Linux


      A DESCRIPTION OF THE PROBLEM :
      For JButton, setPressedIcon or rollover icon, etc, does not work, unless the button also has its icon set (setIcon()).



      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Run the attached code (create an icon with a name "selectedIcon.gif", and put it in a same source package as that of the source file).

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      When mouse press on the button, it should change the back ground to reflect the icon.
      ACTUAL -
      Nothing change.

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      package aaaaa;

      import javax.swing.SwingUtilities;

      public class NewJFrame extends javax.swing.JFrame {

          public NewJFrame() {
              initComponents();
              SwingUtilities.updateComponentTreeUI(this);
              this.pack();
          }
          
          private void initComponents() {

              jButton1 = new javax.swing.JButton();

              setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

              jButton1.setText("jButton1");
              jButton1.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
              jButton1.setPressedIcon(new javax.swing.ImageIcon(getClass().getResource("/aaaaa/selectedIcon.gif"))); // NOI18N
              jButton1.setSelected(true);
              getContentPane().add(jButton1, java.awt.BorderLayout.CENTER);

              java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
              setBounds((screenSize.width-340)/2, (screenSize.height-291)/2, 340, 291);
          }

          public static void main(String args[]) {
              java.awt.EventQueue.invokeLater(new Runnable() {
                  public void run() {
                      new NewJFrame().setVisible(true);
                  }
              });
          }
         
          private javax.swing.JButton jButton1;
      }

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

        Attachments

          Activity

            People

            Assignee:
            Unassigned Unassigned
            Reporter:
            ryeung Roger Yeung (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Dates

              Created:
              Updated:
              Imported:
              Indexed: