JDK-6386636 : REGRESSION: JToggleButton in JToolbar with windows XP look and feel truncated
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 6
  • Priority: P2
  • Status: Closed
  • Resolution: Duplicate
  • OS: generic
  • CPU: generic
  • Submitted: 2006-02-16
  • Updated: 2011-01-19
  • Resolved: 2006-02-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
6Resolved
Related Reports
Duplicate :  
Description
A DESCRIPTION OF THE REGRESSION :
Sometimes (when doing goofy insets things) the text in buttons gets truncated (possibly all the way to "...") when added to a  toolbar with goofy things done to the insets, like NetBeans does!

REPRODUCIBLE TESTCASE OR STEPS TO REPRODUCE:
//Based on code from
//http://www.netbeans.org/source/browse/core/multiview/src/org/netbeans/core/multiview/TabsComponent.java?rev=1.17&content-type=text/vnd.viewcvs-markup
package mustang;

import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.GridBagConstraints;
import java.awt.Insets;
import java.util.ArrayList;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JToggleButton;
import javax.swing.JToolBar;
import javax.swing.UIManager;

public class InsetsSizes {
    
    public static void main(String[] args) throws Exception {
        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
        JFrame f = new JFrame("Margins test");
        f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        JToolBar bar = new JToolBar();
        f.add(bar, BorderLayout.NORTH);

        String[] descs = new String[] {"Source", "Design"};
                
        int prefHeight = -1;
        int prefWidth = -1;
        ArrayList<JToggleButton> buttons = new ArrayList<JToggleButton>();
        for (int i = 0; i < descs.length; i++) {
            JToggleButton button = createButton(descs[i]);
            buttons.add(button);
            //model.getButtonGroup().add(button);
            GridBagConstraints cons = new GridBagConstraints();
            cons.anchor = GridBagConstraints.WEST;
            prefHeight = Math.max(button.getPreferredSize().height, prefHeight);
            bar.add(button, cons);
            prefWidth = Math.max(button.getPreferredSize().width, prefWidth);
            //if (descs[i] == model.getActiveDescription()) {
            //    active = button;
                
            //}
        }
        for (JToggleButton but : buttons) {
            Insets ins = but.getBorder().getBorderInsets(but);
            but.setPreferredSize(new Dimension(prefWidth + 10, prefHeight));
            but.setMinimumSize(new Dimension(prefWidth + 10, prefHeight));
        }
        
        f.add(new JLabel("<html>You should see \"Soruce\" and <br>\"Design\" in the toolbar.  If <br>they are truncated with \"...\" <br>the bug is present"), BorderLayout.CENTER);
        
        f.pack();
        f.setVisible(true);
        
    }
    
    public static JToggleButton createButton(String name) {
        return new JToggleButton(name);

    }
}


RELEASE LAST WORKED:
5.0 Update 6

RELEASE TEST FAILS:
mustang-b70

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
both the text 'Source' and 'Design' show up completely in the button
ACTUAL -
Actually breaks in b71, may break earlier

When run on Windows XP with the Luna theme the buttons show "Sou..." and "Des..."

APPLICATION NAME: Netbeans	APPLICATION VERSION: 5.0

OBSERVED APPLICATION IMPACT:
When using the form designer you get "..." and "..." for the buttons to switch between code and form view.  Works fine with java 5.0

Release Regression From : 5.0u6
The above release value was the last known release where this 
bug was known to work. Since then there has been a regression.

Comments
EVALUATION This looks it may be an issue only under the Windows L&F.
16-02-2006