Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-6386636

REGRESSION: JToggleButton in JToolbar with windows XP look and feel truncated

    XMLWordPrintable

    Details

      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.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              jmarinacsunw Joshua Marinacci (Inactive)
              Reporter:
              dbessono Dmitry Bessonov
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: