JDK-6696166 : TitledBorder: default title position isn't changed if current Look and Feel has changed
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 6u10
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2008-04-30
  • Updated: 2011-02-16
  • Resolved: 2008-06-09
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
6u10 b26Fixed
Related Reports
Relates :  
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
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.
30-04-2008

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.
30-04-2008