United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
JDK-6818229 : Nimbus LookAndFeel does not paint alternate row colors

Details
Type:
Bug
Submit Date:
2009-03-17
Status:
Closed
Updated Date:
2011-01-19
Project Name:
JDK
Resolved Date:
2009-05-18
Component:
client-libs
OS:
linux
Sub-Component:
javax.swing
CPU:
x86
Priority:
P2
Resolution:
Fixed
Affected Versions:
6u10
Fixed Versions:
6u14 (b04)

Related Reports

Sub Tasks

Description
FULL PRODUCT VERSION :
java version "1.6.0_14-ea"
Java(TM) SE Runtime Environment (build 1.6.0_14-ea-b03)
Java HotSpot(TM) Server VM (build 14.0-b12, mixed mode)

ADDITIONAL OS VERSION INFORMATION :
Linux 2.6.27-13-generic #1 SMP Thu Feb 26 07:26:43 UTC 2009 i686 GNU/Linux

A DESCRIPTION OF THE PROBLEM :
Nimbus LookAndFeel usually paints every second row using an alternateRowColor. Selected rows are usually painted using a dark blue color. This feature worked on 1.6.0_10 and 1.6.0_12 but does not work anymore on 1.6.0_14.
The selection background is not painted (remains white).

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
see sourcecode

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Every second row is painted using Table.alternateRowColor. The selection background color is used to paint the background of selected cells.
ACTUAL -
All rows (selected or not) are painted using a white background.

ERROR MESSAGES/STACK TRACES THAT OCCUR :
No error is displayed in the console.

REPRODUCIBILITY :
This bug can be reproduced always.

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


public class NimbusTableError
{
    @SuppressWarnings({"ALL"})
    public static void main(String[] args)
    {
        EventQueue.invokeLater(new Runnable()
        {
            @Override
            public void run()
            {
                initAndShowGUI();
            }
        });
    }


    private static void initAndShowGUI()
    {
        try
        {
            UIManager.LookAndFeelInfo[] installedLookAndFeels = UIManager.getInstalledLookAndFeels();
            UIManager.LookAndFeelInfo nimbusLAFInfo = null;
            for (UIManager.LookAndFeelInfo installedLookAndFeel : installedLookAndFeels)
            {
                if ("Nimbus".equals(installedLookAndFeel.getName()))
                {
                    nimbusLAFInfo = installedLookAndFeel;
                    break;
                }
            }

            if (nimbusLAFInfo != null)
            {
                UIManager.setLookAndFeel(nimbusLAFInfo.getClassName());
            }
        }
        catch (Exception e)
        {
            e.printStackTrace();
        }

        JFrame frame = new JFrame();

        JTable table = new JTable(new AbstractTableModel()
        {
            @Override
            public int getRowCount()
            {
                return 5;
            }


            @Override
            public int getColumnCount()
            {
                return 3;
            }


            @Override
            public Object getValueAt(int rowIndex, int columnIndex)
            {
                return rowIndex + "-" + columnIndex;
            }
        });

        frame.getContentPane().add(new JScrollPane(table));

        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.setBounds(100, 100, 300, 300);
        frame.setVisible(true);
    }
}
---------- END SOURCE ----------

Release Regression From : 6u12
The above release value was the last known release where this 
bug was not reproducible. Since then there has been a regression.

                                    

Comments
EVALUATION

Regression from 6802944. For some reason Synth relies on some colors to be _not_ UIResources. As part of 6802944 fix, generator was changed to generate UIResources only. This should be reverted.
                                     
2009-03-17
SUGGESTED FIX

http://sa.sfbay.sun.com/projects/swing_data/6u14/6818229.0
                                     
2009-03-20



Hardware and Software, Engineered to Work Together