JDK-6818229 : Nimbus LookAndFeel does not paint alternate row colors
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 6u10
  • Priority: P2
  • Status: Closed
  • Resolution: Fixed
  • OS: linux
  • CPU: x86
  • Submitted: 2009-03-17
  • Updated: 2011-01-19
  • Resolved: 2009-05-18
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.
JDK 6
6u14 b04Fixed
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
SUGGESTED FIX http://sa.sfbay.sun.com/projects/swing_data/6u14/6818229.0
20-03-2009

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.
17-03-2009