Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-6788482

Nimbus LAF: JTable selection colors don't update when LAF changed

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P4 P4
    • None
    • 6u10
    • client-libs

      FULL PRODUCT VERSION :
      java version "1.6.0_11"
      Java(TM) SE Runtime Environment (build 1.6.0_11-b03)
      Java HotSpot(TM) Client VM (build 11.0-b16, mixed mode, sharing)

      ADDITIONAL OS VERSION INFORMATION :
      Microsoft Windows [Version 6.0.6001]

      A DESCRIPTION OF THE PROBLEM :
      When the JTable UI is changed from Nimbus to another UI, the selection background and foreground colors are not updated by the new UI. That is, after the UI change, the JTable still displays the foreground selection and background selection colors of the Nimbus look and feel. This is most likely due to the following code in BasicTableUI:

      Color sbg = table.getSelectionBackground();
              if (sbg == null || sbg instanceof UIResource) {
                  sbg = UIManager.getColor("Table.selectionBackground");
                  table.setSelectionBackground(sbg != null ? sbg : UIManager.getColor("textHighlight"));
              }

      Since the Nimbus LAF uses the DerivedColor class for its colors, the look and feels that extend Basic fail to recognize that the selection colors are not user-set colors, and thus will not update the selection colors.

      While this may be a separate issue, I'm sure it comes from similar origins: if a JTable installs the Nimbus LAF, the grid lines vanish. When the JTable installs back to another LAF which previously had grid lines showing, the grid lines do not reappear.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Create a program with a non-empty JTable and the ability to install any LAF found on the system. Run program and switch from non-nimbus to nimbus, and then back to non-nimbus.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      If user has not explicitly set the JTable selection colors, the JTable should honor the selection colors of the ComponentUI.
      ACTUAL -
      JTable fails to honor the selection colors of the ComponentUI after installing over a Nimbus UI.

      REPRODUCIBILITY :
      This bug can be reproduced always.

            Unassigned Unassigned
            igor Igor Nekrestyanov (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: