JDK-7010561 : Tab text position with Synth based LaF is different to Java 5/6
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 7
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • OS: windows_7
  • CPU: x86
  • Submitted: 2011-01-05
  • Updated: 2013-04-22
  • Resolved: 2012-02-07
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 7 JDK 8
7u4Fixed 8 b25Fixed
Related Reports
Duplicate :  
Relates :  
Description
FULL PRODUCT VERSION :
java version "1.7.0-ea"
Java(TM) SE Runtime Environment (build 1.7.0-ea-b121)
Java HotSpot(TM) Client VM (build 20.0-b03, mixed mode)

A DESCRIPTION OF THE PROBLEM :
The text position for selected tabs is different to Java 5/6. On Java 5/6 the selected text is raised by default (2 pixels, compared to unselected tab text). Please find a simple test case below.

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Execute test case with Java 5/6/7 and compare the screens.

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The selected tab (red)  should be raised 2 pixels.
ACTUAL -
The selected tab isn't raised.

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
package test.synth;

import java.awt.Dimension;
import java.awt.EventQueue;
import java.io.ByteArrayInputStream;
import java.io.InputStream;

import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JTabbedPane;
import javax.swing.UIManager;
import javax.swing.plaf.synth.SynthLookAndFeel;

public class SynthTabbedPaneTest extends JFrame
{
  private static String synthXml = "<synth>" +
  "  <style id=\"all\">" +
  "    <font name=\"Dialog\" size=\"12\"/>" +
  "  </style>" +
  "  <bind style=\"all\" type=\"REGION\" key=\".*\"/>" +
  "  <style id=\"tabbedPaneTab\">" +
  "    <state>" +
  "      <color type=\"TEXT_FOREGROUND\" value=\"#800000\"/>" +
  "    </state>" +
  "    <state value=\"SELECTED\">" +
  "      <color type=\"TEXT_FOREGROUND\" value=\"#FF0000\"/>" +
  "    </state>" +
  "  </style>" +
  "  <bind style=\"tabbedPaneTab\" type=\"region\" key=\"TabbedPaneTab\"/>" +
  "</synth>";
  
  public static void main(String[] args)
  {
    EventQueue.invokeLater(new Runnable(){
      public void run()
      {
        try
        {
          new SynthTabbedPaneTest();
        }
        catch (Exception e)
        {
          e.printStackTrace();
        }
      }
    });
  }

  public SynthTabbedPaneTest() throws Exception
  {
    InputStream is = new ByteArrayInputStream(synthXml.getBytes("UTF8"));
    SynthLookAndFeel laf = new SynthLookAndFeel();
    laf.load(is, SynthTabbedPaneTest.class);
    UIManager.setLookAndFeel(laf);

    JTabbedPane tabPane = new JTabbedPane();
    tabPane.addTab("Tab 1", new JLabel("Tab 1"));
    tabPane.addTab("Tab 2", new JLabel("Tab 2"));
    tabPane.addTab("Tab 3", new JLabel("Tab 3"));
    
    add(tabPane);
    
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    setSize(new Dimension(600, 300));
    setLocationRelativeTo(null);
    setVisible(true);
  }
}  


---------- END SOURCE ----------

Comments
EVALUATION This is a regression from CR 5089821 (see changes here http://sa.sfbay.sun.com/projects/swing_data/7/5089821/src/share/classes/javax/swing/plaf/basic/BasicTabbedPaneUI.java.udiff.html). To calculate tab label position new variables "TabbedPane.selectedLabelShift" and "TabbedPane.labelShift" were introduced. But when these variables are not set we should use old values (which were used before fix of CR 5089821) as a default values.
26-01-2012