JDK-4887836 : Exceptions thrown when mouse moved over white area in the JColorChooser Swatch t
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 5.0
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • OS: windows_2000
  • CPU: x86
  • Submitted: 2003-07-09
  • Updated: 2003-08-09
  • Resolved: 2003-08-09
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
5.0 tigerFixed
Related Reports
Relates :  
Relates :  
Description

Name: dk106046			Date: 07/09/2003

java version "1.3.1_06"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.1_06-b01)
Java HotSpot(TM) Client VM (build 1.3.1_06-b01, mixed mode)

The problem is also observed on SUN 131, 142 and also on 150 pre beta.

- Exact steps to reproduce :-

1)Compile the testcase ColorChooserBug.java
  javac ColorChooserBug.java
2)Run the testcase
  java ColorChooserBug
3) Click "Press Here"
4) In the Frame that is displayed, select "swatches" tab.
5) Move the mouse over the white area in the color chooser panel.
6) You will observe runtime errors in the command window.

- Minimal source code that demonstrates the problem :-

/*
 * ColorChooserBug.java
 *
 */
import java.awt.Color;
import javax.swing.UIManager;

public class ColorChooserBug extends javax.swing.JFrame {
    
    /** Creates new form ColorChooserBug */
    public ColorChooserBug() {
        initComponents();
    }
    
    /** 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() {
        jPanel1 = new javax.swing.JPanel();
        jButton1 = new javax.swing.JButton();

        getContentPane().setLayout(new java.awt.GridLayout(5, 5));

        setFont(new java.awt.Font("Perpetua", 0, 48));
        addWindowListener(new java.awt.event.WindowAdapter() {
            public void windowClosing(java.awt.event.WindowEvent evt) {
                exitForm(evt);
            }
        });

        jPanel1.setFont(new java.awt.Font("Perpetua", 0, 48));
        jButton1.setFont(new java.awt.Font("Perpetua", 0, 48));
        jButton1.setText("Press Here");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        jPanel1.add(jButton1);

        getContentPane().add(jPanel1);

        pack();
    }

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
        // Add your handling code here:
        java.awt.Font f = new java.awt.Font("Perpetua", 0, 48);
        UIManager.put("Label.font", f);
        Color chosen = javax.swing.JColorChooser.showDialog(this, "Select a color", Color.lightGray);
    }
    
    /** 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 ColorChooserBug().show();
    }
    
    
    // Variables declaration - do not modify
    private javax.swing.JButton jButton1;
    private javax.swing.JPanel jPanel1;
    // End of variables declaration
    
}


- Exact text of any error messages
Exception occurred during event dispatching:
java.lang.ArrayIndexOutOfBoundsException
at javax.swing.colorchooser.SwatchPanel.getColorForCell(DefaultSwatchChooserPanel.java:208)
at javax.swing.colorchooser.SwatchPanel.getColorForLocation(DefaultSwatchChooserPanel.java:204)
at javax.swing.colorchooser.SwatchPanel.getToolTipText(DefaultSwatchChooserPanel.java:197)
at javax.swing.ToolTipManager.mouseMoved(ToolTipManager.java:520)
at java.awt.Component.processMouseMotionEvent(Component.java:3751)
at javax.swing.JComponent.processMouseMotionEvent(JComponent.java:2294)
at java.awt.Component.processEvent(Component.java:3543)
at java.awt.Container.processEvent(Container.java:1159)
at java.awt.Component.dispatchEventImpl(Component.java:2588)
at java.awt.Container.dispatchEventImpl(Container.java:1208)
at java.awt.Component.dispatchEvent(Component.java:2492)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:2451)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:2244)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:2125)
at java.awt.Container.dispatchEventImpl(Container.java:1195)
at java.awt.Window.dispatchEventImpl(Window.java:923)
at java.awt.Component.dispatchEvent(Component.java:2492)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:334)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:126)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:93)
at java.awt.Dialog.show(Dialog.java:375)
at javax.swing.ColorChooserDialog.show(JColorChooser.java:588)
at javax.swing.JColorChooser.showDialog(JColorChooser.java:115)
at ColorChooserBug.jButton1ActionPerformed(ColorChooserBug.java:59)
at ColorChooserBug.access$100(ColorChooserBug.java:14)
at ColorChooserBug$2.actionPerformed(ColorChooserBug.java:44)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1445)
at javax.swing.AbstractButton$ForwardActionEvents.actionPerformed(AbstractButton.java:1499)
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:373)
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:245)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:211)
at java.awt.Component.processMouseEvent(Component.java:3710)
at java.awt.Component.processEvent(Component.java:3539)
at java.awt.Container.processEvent(Container.java:1159)
at java.awt.Component.dispatchEventImpl(Component.java:2588)
at java.awt.Container.dispatchEventImpl(Container.java:1208)
at java.awt.Component.dispatchEvent(Component.java:2492)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:2451)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:2216)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:2125)
at java.awt.Container.dispatchEventImpl(Container.java:1195)
at java.awt.Window.dispatchEventImpl(Window.java:923)
at java.awt.Component.dispatchEvent(Component.java:2492)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:334)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:126)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:93)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:88)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:80)


======================================================================

Comments
CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: tiger FIXED IN: tiger INTEGRATED IN: tiger tiger-b15
24-08-2004

EVALUATION Name: pzR10082 Date: 07/11/2003 I can reproduce the failure only when i click on the white area. Moving mouse over it doesn't cause exceptions. ###@###.### ====================================================================== Name: keR10081 Date: 07/14/2003 This happens because we use BorderLayout with big font size, while we should rather use another layout manager. ###@###.### ====================================================================== Name: keR10081 Date: 07/18/2003 Internal layout should be corrected like one in suggested fix. ###@###.### ======================================================================
24-08-2004

SUGGESTED FIX Name: keR10081 Date: 07/18/2003 ------- DefaultSwatchChooserPanel.java ------- *** /tmp/sccs.cvaa0i Fri Jul 18 13:33:47 2003 --- DefaultSwatchChooserPanel.java Fri Jul 18 13:29:41 2003 *************** *** 119,125 **** protected void buildChooser() { ! JPanel superHolder = new JPanel(new BorderLayout()); swatchPanel = new MainSwatchPanel(); swatchPanel.getAccessibleContext().setAccessibleName(getDisplayName()); --- 119,127 ---- protected void buildChooser() { ! GridBagLayout gb = new GridBagLayout(); ! GridBagConstraints gbc = new GridBagConstraints(); ! JPanel superHolder = new JPanel(gb); swatchPanel = new MainSwatchPanel(); swatchPanel.getAccessibleContext().setAccessibleName(getDisplayName()); *************** *** 133,162 **** recentSwatchPanel.addMouseListener(recentSwatchListener); - JPanel mainHolder = new JPanel(new BorderLayout()); Border border = new CompoundBorder( new LineBorder(Color.black), new LineBorder(Color.white) ); ! mainHolder.setBorder(border); ! mainHolder.add(swatchPanel, BorderLayout.CENTER); ! superHolder.add( mainHolder, BorderLayout.CENTER ); - JPanel recentHolder = new JPanel( new BorderLayout() ); recentSwatchPanel.addMouseListener(recentSwatchListener); ! recentHolder.setBorder(border); ! recentHolder.add(recentSwatchPanel, BorderLayout.CENTER); JPanel recentLabelHolder = new JPanel(new BorderLayout()); - recentLabelHolder.add(recentHolder, BorderLayout.CENTER); JLabel l = new JLabel(recentStr); l.setLabelFor(recentSwatchPanel); recentLabelHolder.add(l, BorderLayout.NORTH); ! JPanel recentHolderHolder = new JPanel(new CenterLayout()); ! if (this.getComponentOrientation().isLeftToRight()) { ! recentHolderHolder.setBorder(new EmptyBorder(2,10,2,2)); ! } else { ! recentHolderHolder.setBorder(new EmptyBorder(2,2,2,10)); ! } ! recentHolderHolder.add(recentLabelHolder); ! superHolder.add( recentHolderHolder, BorderLayout.AFTER_LINE_ENDS ); add(superHolder); --- 135,160 ---- recentSwatchPanel.addMouseListener(recentSwatchListener); Border border = new CompoundBorder( new LineBorder(Color.black), new LineBorder(Color.white) ); ! swatchPanel.setBorder(border); ! gbc.weightx = 1.0; ! gbc.gridwidth = 2; ! gbc.gridheight = 2; ! gbc.weighty = 1.0; ! superHolder.add( swatchPanel, gbc ); recentSwatchPanel.addMouseListener(recentSwatchListener); ! recentSwatchPanel.setBorder(border); JPanel recentLabelHolder = new JPanel(new BorderLayout()); JLabel l = new JLabel(recentStr); l.setLabelFor(recentSwatchPanel); recentLabelHolder.add(l, BorderLayout.NORTH); ! gbc.weighty = 0.0; ! gbc.gridwidth = GridBagConstraints.REMAINDER; ! gbc.gridheight = 1; ! superHolder.add( recentLabelHolder, gbc ); ! superHolder.add( recentSwatchPanel, gbc ); add(superHolder); ======================================================================
24-08-2004