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

Positioning Components in JToolBar is wrong

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P5 P5
    • None
    • 1.1.5
    • client-libs
    • None

      This bug is reproducible on NT and Solaris

      Y position in the toolbar is not identical. JComboBox is drawn higher than the JButton. Problem only occurs when adding both components.

      JDK 1.1.5, Swing 0.7

      ************** SOURCES: ********************

      // ### FILE: Main.java ###

      public class Main
      {
      public static void main (String args[])
      {
      HelpWindow helpWin = new HelpWindow ("Toolbar Test");
      helpWin.setLocation (100, 100);
      helpWin.setSize (800, 600);
      helpWin.setVisible (true);
      return;
      }
      }

      // ### FILE: HelpWindow.java ###

      import java.awt.*;
      import java.awt.event.*;

      import com.sun.java.swing.*;

      public class HelpWindow extends JFrame
      {
      JRootPane m_RootPanel = new JRootPane ();
      JPanel m_MainPanel = new JPanel();

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



      // *** create Toolbar ***

      JToolBar toolBar = new JToolBar();
      toolBar.setMaximumSize (new Dimension (400, 15));

      // --- add Button

      JButton b = (JButton) toolBar.add(new JButton("any"));
      b.setMargin(new Insets(0, 0, 0, 0));
      b.setPreferredSize (new Dimension (25, 25));

      toolBar.addSeparator();

      // --- add ComboBox

      JComboBox c = new JComboBox();
      c.addItem ("item");
      c.setMaximumSize (new Dimension (120, 25));
      toolBar.add (c);
      toolBar.setBackground (Color.lightGray);


      // *** create MainPanel: North: Toolbar, Center: empty (JPanel) ***

      m_MainPanel.setLayout (new BorderLayout());
      m_MainPanel.add ("North", toolBar);
      m_MainPanel.add ("Center", new JPanel());

      m_RootPanel.getContentPane().setLayout (new BorderLayout());
      m_RootPanel.getContentPane().add (m_MainPanel);

      setRootPane (m_RootPanel);
      }
      }

            gsaab Georges Saab
            tviessma Thomas Viessmann (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: