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

REGRESSION: JColorChooser.setPreviewPanel() does not show custom preview panel

XMLWordPrintable



      Name: rmT116609 Date: 04/08/2004


      FULL PRODUCT VERSION :
      java version "1.4.2"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2-b28)
      Java HotSpot(TM) Client VM (build 1.4.2-b28, mixed mode)

      java version "1.5.0-beta"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-beta-b32c)
      Java HotSpot(TM) Client VM (build 1.5.0-beta-b32c, mixed mode)

      FULL OS VERSION :
      Microsoft Windows XP [Version 5.1.2600]

      A DESCRIPTION OF THE PROBLEM :
      With j2re1.4.2 JColorChooser does not show a custom preview panel, that was set with JColorChooser.setPreviewPanel(). Instead the default preview panel is removed and the space is left blank. This happens with code, that was perfectly working in 1.4.1_02 and prior versions. It happens with metal L&F and windows L&F. It is still possible to use the default preview panel.

      I already tested this with 1.5.0 beta1 before and it seems to work if you set a JButton as the new previewPanel but fails with all other JComponents.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Execute the given code in 1.4.1_02 and 1.4.2. The preview panel shows up with 1.4.1_02 but not with 1.4.2.

      The code just constructs a JColorChooser within a JFrame and sets a custom preview panel, which is a JLabel in this case.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      I would expect the custom preview panel to appear on screen.
      ACTUAL -
      Custom preview panel does not show up, default preview panel is removed and space left blank.

      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      No error messages.

      REPRODUCIBILITY :
      This bug can be reproduced always.

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

      public class JColorChooserTest extends javax.swing.JFrame {
          
          /** Creates new form JcolorChooserTest */
          public JColorChooserTest() {
              initComponents();

              PreviewPanel previewPanel = new PreviewPanel();
              jColorChooser1.setPreviewPanel(previewPanel);
              jColorChooser1.getSelectionModel().addChangeListener(previewPanel);
          }
          
          /** This method is called from within the constructor to
           * initialize the form.
           * WARNING: Do NOT modify this code. The content of this method is
           * always regenerated by the Form Editor.
           */
          private void initComponents() {
              jColorChooser1 = new javax.swing.JColorChooser();

              getContentPane().setLayout(new java.awt.FlowLayout());

              addWindowListener(new java.awt.event.WindowAdapter() {
                  public void windowClosing(java.awt.event.WindowEvent evt) {
                      exitForm(evt);
                  }
              });

              getContentPane().add(jColorChooser1);

              pack();
          }
          
          /** Exit the Application */
          private void exitForm(java.awt.event.WindowEvent evt) {
              System.exit(0);
          }
          
          /**
           * @param args the command line arguments
           */
          public static void main(String args[]) {
              new JColorChooserTest().show();
          }
          
          
          // Variables declaration - do not modify
          private javax.swing.JColorChooser jColorChooser1;
          // End of variables declaration
          
          class PreviewPanel extends JLabel implements javax.swing.event.ChangeListener{
              
              public PreviewPanel() {
                  super("This is the selected color!");
              }
              
              public void stateChanged(javax.swing.event.ChangeEvent e) {
                  Color newColor = jColorChooser1.getColor();
                  setForeground(newColor);
              }
              
          }
      }
      ---------- END SOURCE ----------

      Release Regression From : 1.4.1
      The above release value was the last known release where this
      bug was known to work. Since then there has been a regression.

      (Incident Review ID: 189871)
      ======================================================================

            alexp Alexander Potochkin (Inactive)
            rmandalasunw Ranjith Mandala (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: