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

JToolBar uses wrong interior padding w/ Windows LF

XMLWordPrintable

    • beta
    • generic, x86
    • generic, windows_nt



      Name: wl91122 Date: 09/02/99


      When compared to the native look and feel of Windows apps, the
      JToolBar's interior padding(ie the distance from its border to
      the buttons contained in it) is incorrect. You can see this by
      comparing a native Windows app that doesn't have the rollover
      toolbar effect(like WordPad) to one created using Swing. The
      code below creates a simple toolbar with three buttons. On a
      native Windows app the interior padding is roughly 3 pixels above
      and below the contained buttons and 4 pixels on the far left
      and right(these are eye-balled). The JToolBar, using the Windows
      LF doesn't provide any padding, which makes it different from the
      the native appearance it's suppose to be emulating.

      When invoking the test app if you don't supply any command-line
      args the LF is Metal. If any args are supplied the LF is Windows.

      Here's the code:

      import java.awt.*;
      import java.awt.event.*;
      import javax.swing.*;

      public class bug extends JFrame {

          public static void main(String args[]) {
              if (args.length > 0) {
                  try {
                      UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
                  } catch (Exception e) {}
              }
              new bug();
          }
          public bug() {

              addWindowListener(new WindowAdapter() {
                  public void windowClosing(WindowEvent e) {System.exit(0);}
              });

              JToolBar toolbar = new JToolBar();
              toolbar.add(new JButton("Button1"));
              toolbar.add(new JButton("Button2"));
              toolbar.add(new JButton("Button3"));

              getContentPane().add(toolbar, BorderLayout.NORTH);
              pack();
              setSize(300,100);
              setVisible(true);
          }
      }
      (Review ID: 94800)
      ======================================================================

      Name: krT82822 Date: 09/27/99


      In my program i use abstract actions to create my buttons which
      are added to a toolbar. When using the metal look and feel, the
      buttons in the toolbar are squares (the used icons are all
      16 * 16 pixels in size). But when using the windows
      look and feel they are much wider than high. Even when setting
      the margin with the setMargin method of button, the problem is
      not resolved because this method seems not to work properly
      (at least for the vertical margin).

      This is how i create my buttons and the toolbar
      ...
      JToolBar toolBar = new JToolBar();
      Action act;
      JButton button;
      button = toolBar.add(act);
      ...
      (Review ID: 95766)
      ======================================================================

            amfowler Anne Fowler (Inactive)
            wleesunw William Lee (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: