United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: JDK-7010561 Tab text position with Synth based LaF is different to Java 5/6
JDK-7010561 : Tab text position with Synth based LaF is different to Java 5/6

Details
Type:
Bug
Submit Date:
2011-01-05
Status:
Resolved
Updated Date:
2013-04-22
Project Name:
JDK
Resolved Date:
2012-02-07
Component:
client-libs
OS:
windows_7
Sub-Component:
javax.swing
CPU:
x86
Priority:
P4
Resolution:
Fixed
Affected Versions:
7
Fixed Versions:

Related Reports
Backport:
Duplicate:
Relates:

Sub Tasks

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.
                                     
2012-01-26



Hardware and Software, Engineered to Work Together