United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
JDK-4912559 : JFileChooser filepanel background color is unlike native mercury

Details
Type:
Bug
Submit Date:
2003-08-26
Status:
Resolved
Updated Date:
2003-11-17
Project Name:
JDK
Resolved Date:
2003-11-17
Component:
client-libs
OS:
linux_sun
Sub-Component:
javax.swing
CPU:
x86
Priority:
P4
Resolution:
Fixed
Affected Versions:
1.4.2_01
Fixed Versions:
1.4.2_04 (04)

Related Reports

Sub Tasks

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
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
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



Hardware and Software, Engineered to Work Together