JDK-5027285 : Wrong background color for JTrees using DefaultTreeCellRenderer on GTK L&F
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 5.0
  • Priority: P3
  • Status: Closed
  • Resolution: Not an Issue
  • OS: linux
  • CPU: x86
  • Submitted: 2004-04-06
  • Updated: 2004-04-09
  • Resolved: 2004-04-09
Related Reports
Duplicate :  
Relates :  
Description
Found while diagnosing tree painting problems in NetBeans on GTK L&F...

It appears that any use of DefaultTreeCellRenderer results in the tree cell being painted as grey, regardless of the color with which the tree is painted.  I replaced our custom renderer with code which, for each paint, simply created a new DefaultTreeCellRenderer and set its text and icon, and the painting bug remained - so the problem is definitely not our code.

The culprit appears to be 
SynthTreeUI.configureRenderer()

The result of this problem is that
 - Trees are rendered as white
 - The background color of the text of tree nodes is rendered as gray
 - When selected, the background color of the text of tree nodes is a slightly different shade of blue than the stripe indicating the selection

Comments
EVALUATION Name: omR10226 Date: 04/08/2004 Our tree behavior is coping native tree behavior. Native gtk tree view uses text_background color to fill background of cells and to fill background around of cell too. So: - Trees are rendered as white It's normal. Just look at native. - The background color of the text of tree nodes is rendered as gray I think it's mostly connected with 5027331. - When selected, the background color of the text of tree nodes is a slightly different shade of blue than the stripe indicating the selection It's possible if you are using custom renderer, and will be fixed with 5027331. To check my words please create in your home directory file .gtkrc-2.0 with the following contents: style "treetest" { bg[NORMAL]="#e234d6" base[NORMAL]="#b8e333" base[SELECTED]="#1c48fb" } class "GtkTreeView" style "treetest" Then launch any native app with tree view (e.g. gtk-demo ). You will see that background of tree is a text_background color defined in our .gtkrc-2.0 (base[NORMAL]="#b8e333"). Selection color is correspond to base[SELECTED]="#1c48fb" - blue. You may mention that bg[NORMAL]="#e234d6" wasn't used. Now launch swing app with tree and compare result with native. All color in swing app is like native. And method JTree.getBackground returns exactly #e234d6. public static void main(String args[]) throws Exception { UIManager.setLookAndFeel("com.sun.java.swing.plaf.gtk.GTKLookAndFeel"); final JTree tree = new JTree(); JFrame frame = new JFrame(); JPanel p = new JPanel(); p.setLayout(new FlowLayout()); JButton b = new JButton("print JTree.getBackground"); b.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { System.out.println("JTree.getBackground: " + tree. } }); p.add(b); p.add(tree); frame.getContentPane().add(p); frame.pack(); frame.setVisible(true); } ====================================================================== Name: omR10226 Date: 04/09/2004 To receive a text background color you could use UIManager.getColor("Tree.textBackground"). For GTK it will return correct color after integation of the fix for 5027331. ======================================================================
11-06-2004

WORK AROUND Do not use/support GTK look and feel, modify all code in product to avoid ever using DefaultTreeCellRenderer
11-06-2004

SUGGESTED FIX Ensure that cells are painted with the correct background color.
11-06-2004