Skip to main content

Tab text position on Java 7b121 with Synth based LaF

Please note these java.net forums are being decommissioned and use the new and improved forums at https://community.oracle.com/community/java.
1 reply [Last post]
wzberger
Offline
Joined: 2004-08-31

Swing/Synth issue with JTabbedPane.

On Java 7b121 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.

 

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); 
  } 

Thanks,

Wolfgang

www.jyloo.com

 

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
robilad
Offline
Joined: 2004-05-05

If the issue persists with the latest build, please report a bug at http://bugreport.sun.com/bugreport/ .
Dalibor Topic, Java F/OSS Ambassador, Java Products Group, Oracle