United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: JDK-6696166 TitledBorder: default title position isn't changed if current Look and Feel has changed
JDK-6696166 : TitledBorder: default title position isn't changed if current Look and Feel has changed

Details
Type:
Bug
Submit Date:
2008-04-30
Status:
Resolved
Updated Date:
2011-02-16
Project Name:
JDK
Resolved Date:
2008-06-09
Component:
client-libs
OS:
generic
Sub-Component:
javax.swing
CPU:
generic
Priority:
P3
Resolution:
Fixed
Affected Versions:
6u10
Fixed Versions:
6u10 (b26)

Related Reports
Relates:

Sub Tasks

Description
jdk version: 6u10
OS: any

If an application uses titled borders and starts under Numbus Look and Feel and then sets another Look and Feel (for example, Metal), all titled borders don't change their title positions.

To reproduce the problem use TitledBorderTest.java from the attachment:
1. Run the test
2. Note that it is the Metal Look and Feel and that the title position is ABOVE_TOP instead of CENTER (screenshot WrongTitlePosition.JPG).
3. Comment the 11th line in the test: // setLaF(LAF.NIMBUS);
4. Run the test again and note that the title position is correct (screenshot ProperTitlePosition.JPG).

More specifically:
If a Look and Feel sets the "TitledBorder.position" UI property and if an application uses this L&F at first and then changes it to another L&F that doesn't set the property, titled border position is turned out wrong. It becomes the same as the default position of the first L&F instead of the default position of the second one.

                                    

Comments
EVALUATION

The bug is caused by the fix for 6595814.

The problem is in the TitledBorder.getTitlePosition() method. If the title position is DEFAULT_POSITION and if the current L&F defined "TitledBorder.position" UI property, the method replaces the current position by UI property's value. The method "forgets" that the position was default.

A solution can be to remember about DEFAULT_POSITION and track changes of current L&F.
                                     
2008-04-30
WORK AROUND

There are several workarounds:
1. Call setTitlePosition() for every titled border.
2. Define "TitledBorder.position" UI property.
3. Don't switch Nimbus to other Look and Feels.
                                     
2008-04-30



Hardware and Software, Engineered to Work Together