JDK-4893911 : Button size gets bigger after a call to SwingUtilities.UpdateComponentTreeUI
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 1.4.2
  • Priority: P3
  • Status: Closed
  • Resolution: Duplicate
  • OS: generic
  • CPU: generic
  • Submitted: 2003-07-22
  • Updated: 2003-09-18
  • Resolved: 2003-09-05
Related Reports
Duplicate :  
Description
Customer comments:

I have attached  two screenshots and a jar file containing modified
'Notedpad' demo. This modified demo shows an issue we have in our 
application.

Please unjar the attachment and execute 'java -cp . Notepad' inside the
Notepad directory. Note the button sizes and click  on 'test' button to
see the bug effect.

ISSUE:

If you do not explicitly set  margin/insets to buttons in a toolbar and
later if you execute 'SwingUtilities.UpdateComponentTreeUI' on the
parent component, the toolbuttons suddenly become bigger.

I did some investigation and it looks like, after the UpdateUI call,
the inside border values of the button's compound border changes from
the default( 3,3,3,3) to the current margin.

Ofcourse if you explicitly set a margin it fixes the problem. But there
seems to be a bug in the way the buttons are rendered pre/post updateUI
call.

Comments
WORK AROUND Explicitly set a margin to the button.
11-06-2004

EVALUATION Name: ibR10256 Date: 09/02/2003 Bug is not reproducible since 4886944 was fixed. When a button is created it gets the default border which is a UIResource instance. When a button is added to a JToolBar its border is set to the return value of BasicToolBarUI.createNonRolloverBorder(). createNonRolloverBorder() returns a CompoundBorder instance since 4886944 was fixed, but it returned CompoundBorderUIResource before. In the example included in the bug description the problem appears after a SwingUtilities.updateComponentTreeUI(panel) call. But actually it was enough to make a button.updateUI() call to get the button's border changed. Method LookAndFeel.installBorder(button, ..) is called as a result of a button.updateUI() call. Here the button's border is changed to the default border in case if it's a UIResource instance. So before 4886944 was fixed the border was re-set to the default one after an updateUI call because when the button was added to the toolbar it got a border that was a UIResource instance. ###@###.### 2003-09-02 ====================================================================== Name: ibR10256 Date: 09/09/2003 I closed the bug as a duplicate of 4886944 since it had a similar cause and was fixed by that bug. ###@###.### 2003-09-09 ======================================================================
09-09-2003