JDK-5029514 : Synth style font binded to ENABLED "tabbedpanetab" affects only SELECTED tabs
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 5.0
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • OS: windows_xp
  • CPU: x86
  • Submitted: 2004-04-09
  • Updated: 2005-10-18
  • Resolved: 2005-08-17
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
6 b48Fixed
Related Reports
Relates :  
Description
Name: ibR10256			Date: 04/09/2004


STEPS TO REPRODUCE:
Compile and run the following sample:

-- SynthStyleTest.java --------
import javax.swing.*;
import javax.swing.plaf.synth.SynthLookAndFeel;
import java.awt.*;
import java.io.*;
import java.text.ParseException;

public class SynthStyleTest {
    public static void main(String[] args) {
        SynthLookAndFeel slf = new SynthLookAndFeel();
        try {
            slf.load(new FileInputStream("style.xml"), SynthStyleTest.class);
            UIManager.setLookAndFeel(slf);
        } catch (Exception e) {
            e.printStackTrace();
            return;
        }

        JFrame frame = new JFrame();
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        Container pane = frame.getContentPane();
        pane.setLayout(new FlowLayout());
        
        JTabbedPane tp = new JTabbedPane();
        tp.add("Tab1", new JLabel("The first tab is selected"));
        tp.add("Tab2", new JLabel("The second tab is selected"));
        tp.add("Tab3", new JLabel("The third tab is selected" ));
        frame.add(tp);

        frame.pack();
        frame.setVisible(true);
    }
}
-------------------------------

-- style.xml ------------------
<synth>
    <style id="tabbedpanetab">
        <state value="ENABLED">
           <font name="Courier" style="BOLD" size="12"/>
           <color value="RED" type="TEXT_FOREGROUND"/>
        </state>
    </style>
    <bind style="tabbedpanetab" type="region" key="tabbedpanetab"/>
</synth>
-------------------------------

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
All visible tab titles should be painted in red with the bold Courier
font specified in style.xml, as all the visible tabs are ENABLED.

ACTUAL -
All tab titles are painted in red but only the selected tab title is
painted with the bold font specified for the ENABLED state.

REPRODUCIBILITY :
This bug can be reproduced always.
---------------------------------------------

======================================================================

Comments
WORK AROUND Name: ibR10256 Date: 04/09/2004 Binding the style to both "tabbedpane" and "tabbedpanetab" regions workarounds the problem: <synth> <style id="tabbedpanetab"> ... </style> <bind style="tabbedpanetab" type="region" key="tabbedpanetab"/> <bind style="tabbedpanetab" type="region" key="tabbedpane"/> </synth> ======================================================================
28-09-2004

SUGGESTED FIX Name: ibR10256 Date: 04/09/2004 To remove this confusion we can add a "not-a-subregion" condition to the ENABLED state check in SynthStyle.getFont(): --- DefaultSynthStyle.java Wed Apr 7 15:56:25 2004 *************** *** 203,209 **** } public Font getFont(JComponent c, Region id, int state) { ! if (state == SynthConstants.ENABLED) { return c.getFont(); } Font cFont = c.getFont(); --- 203,209 ---- } public Font getFont(JComponent c, Region id, int state) { ! if (!id.isSubregion() && state == SynthConstants.ENABLED) { return c.getFont(); } Font cFont = c.getFont(); So binding a style to "tabbedpanetab" will apply for all states, binding to "tabbedpane" will not make any effect on tab titles. The same check is performed already in getColor(), but for some reason not in getFont(). ###@###.### 2004-04-09 ======================================================================
09-04-2004

EVALUATION Name: ibR10256 Date: 04/09/2004 There is a confusion between the "tabbedpane" and "tabbedpanetab" regions. The font specified in a style file for the ENABLED state is installed on JTabbedPane and is used to paint unselected and unfocused tab titles only in case if the corresponding style is binded to the "tabbedpane" region, not "tabbedpanetab". Note that this style is applied only to the ENABLED state (if no additional bindings specified), so the default component's font is used for tab titles in the other states. When the style is binded to "tabbedpanetab" the font specified in the style is not installed on the widget and the default component's font is used for ENABLED tabs, though at the same time the font specified in the style is used in all the other tab states. ###@###.### 2004-04-09 ======================================================================
09-04-2004