JDK-4912559 : JFileChooser filepanel background color is unlike native mercury
  • Type: Bug
  • Status: Resolved
  • Resolution: Fixed
  • Component: client-libs
  • Sub-Component: javax.swing
  • Priority: P4
  • Affected Version: 1.4.2_01
  • OS: linux_sun
  • CPU: x86
  • Submit Date: 2003-08-26
  • Updated Date: 2003-11-17
  • Resolved Date: 2003-11-17
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 Availabitlity Release.

To download the current JDK release, click here.
Other
1.4.2_04 04Resolved
Description
JFileChooser filepanel background color is unlike native mercury filedialog file panel background.

The background color of the area having list items is different than background color of the list part without items.
For instance if there are 3 items in the file list, than background color of these 3 items is different than the remaining list background color. This is unlike native where background color is same for both.


Steps to Reproduce:
-------------------
1) Run SwingSet2 on Mercury with -Dswing.gtkthemefile=<Your .gtkrc File>. Change the Look And Feel to GTK.
2) Go to FileChooser Demo. 
3) Click on button 'Show Plain JFileChooser' and notice the background color of folder and file list.
4) Now open Gedit.
5) Click Open and notice the background color of folder and file list. 
It is same through out the list, It is different than java implementation of the same.

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

EVALUATION Name: omR10226 Date: 09/08/2003 The bug is non-reproducible with Tiger. I'll close bug as not reproducible. ====================================================================== Name: pzR10082 Date: 10/08/2003 Fix for 4787464 has fixed this problem in Tiger by overriding DefaultListCellRenderer.isOpaque(). The overriden method returns false for cell renderers so their background is not painted. Porting this fix back into 1.4.2_03 may be risky, so we may just override isOpaque() in two GTKFileChooser inner classes: FileCellRenderer and DirectoryCellRenderer. ###@###.### ======================================================================
2004-08-24

SUGGESTED FIX Name: pzR10082 Date: 10/09/2003 *** /net/crown/export1/zpm/webrev/src/share/classes/com/sun/java/swing/plaf/gtk/GTKFileChooserUI.java- Wed Oct 8 18:43:30 2003 --- GTKFileChooserUI.java Wed Oct 8 18:34:14 2003 *************** *** 716,721 **** --- 716,734 ---- setText(getFileChooser().getName((File) value)); return this; } + + public boolean isOpaque() { + Color back = getBackground(); + Component p = getParent(); + if (p != null) { + p = p.getParent(); + } + // p should now be the JList. + boolean colorMatch = (back != null) && (p != null) && + back.equals(p.getBackground()) && + p.isOpaque(); + return !colorMatch && super.isOpaque(); + } } protected class DirectoryCellRenderer extends DefaultListCellRenderer { *************** *** 726,731 **** --- 739,757 ---- setText(getFileChooser().getName((File) value) + "/"); return this; } + + public boolean isOpaque() { + Color back = getBackground(); + Component p = getParent(); + if (p != null) { + p = p.getParent(); + } + // p should now be the JList. + boolean colorMatch = (back != null) && (p != null) && + back.equals(p.getBackground()) && + p.isOpaque(); + return !colorMatch && super.isOpaque(); + } } public Dimension getPreferredSize(JComponent c) { ###@###.### ======================================================================
2004-08-24