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

Adding JSeparator to JToolBar "pushes" buttons added after separator to edge

    XMLWordPrintable

Details

    • b11
    • x86
    • windows_nt, windows_xp

    Description

      Name: jk109818 Date: 06/19/2000


      Classic VM (build JDK-1.2.2-W, native threads, symcjit)

      Adding buttons in a JToolBar after a JSeparator will push the button to the far
      right (for a toolbar anchored at the top).

      I have tried may different methods (including overriding the LayoutManager for
      JToolBar, adding a Box.createGlue() after the separator), but nothing "logical"
      keeps the buttons added after the separator next to the separator.

      Here is a source file showing the behavior.

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

      public class ToolBarTest
      {

      ToolBarTest()
      {
      JFrame frame = new JFrame("Troy's ToolBarTest");

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

      JToolBar toolBar = buildToolBar();
      frame.getContentPane().setLayout(new BorderLayout());
      frame.getContentPane().add(toolBar, BorderLayout.NORTH);
      frame.getContentPane().add(new JPanel(), BorderLayout.CENTER);
      frame.setSize(400,200);
      frame.show();
      }

      JToolBar buildToolBar()
      {
      JToolBar toolBar = new JToolBar();
      toolBar.add(new JButton("button 1"));
      toolBar.add(new JButton("button 2"));
      toolBar.add(new JSeparator(SwingConstants.VERTICAL));
      toolBar.add(new JButton("button 3"));

      return toolBar;
      }

      public static void main(String[] args)
      {
      ToolBarTest test = new ToolBarTest();
      }
      }
      (Review ID: 105252)
      ======================================================================

      Attachments

        Issue Links

          Activity

            People

              psadhukhan Prasanta Sadhukhan
              jkimsunw Jeffrey Kim (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: