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

Regression: jdk1.4.0-b50, JToolBar wont stick to right side JFrame

    Details

    • Subcomponent:
    • Resolved In Build:
      beta
    • CPU:
      x86
    • OS:
      generic
    • Verification:
      Verified

      Description



      Name: jbT81659 Date: 02/08/2001


      OS: All tested platforms (Windows, Solaris, Linux)
      JDK: jdk1.4.0-Beta50

      JToolBar wont stick to righthand side of JFrame.
      To reproduce bug:
      1- Compile and run attached code under any OS you choose.
      2- When application is displayed on screen, use the mouse
          to grap JToolBar from one of its ends(right or left).
      3- Drag the JToolBar to bottom border of JFrame and release it.
      4- Note that JToolBar sticks to bottom JFrame border
      5- Drag JToolBar in the same way to Left side JFrame border and
         release it.
      6- Note that JToolBar sticks to Left JFrame border
      7- Drag JToolBar in the same way to RIGHT side JFrame border and
         release it.
      8- Note that JToolBar wont stick to rightside JFrame border

      ----------------Code-----------------
      /* Copyright (c) Sun Microsystems 1998

      $Header: /home/sun/src/JDK1.2/jToolBar.java,v 1.12 2000/03/30 08:13:08 isam Exp $

      */

      import javax.swing.*;
      import javax.swing.JToolBar;
      import javax.swing.JButton;
      import javax.swing.JFrame;
      import javax.swing.JTextArea;
      import javax.swing.JScrollPane;
      import javax.swing.JPanel;
      import java.awt.*;
      import java.awt.event.*;

      public class jToolBar extends JApplet
      {
              public void init()
              {
                      ToolBarDemo toolbar = new ToolBarDemo();
                      getContentPane().add(toolbar);
              }
              
              public static void main(String[] argv)
              {
                      JFrame frame = new JFrame("\u0645\u062b\u0627\u0644");
                      frame.setContentPane(new ToolBarDemo());
                      frame.pack();
                      frame.setVisible(true);
              frame.addWindowListener( new WindowAdapter()
              {
                   public void windowClosing( WindowEvent e)
                   {
                       System.exit(0);
                   }
              });

              }
      }
      class ToolBarDemo extends JPanel
      {
              protected JTextArea textArea;
              protected String newline = "\n";

              public ToolBarDemo()
              {

                      JToolBar toolBar = new JToolBar();
                      addButtons(toolBar);

                      textArea = new JTextArea(10, 30);
                      textArea.setFont(new Font("Lucida Sans Regular",Font.PLAIN,8));
                      JScrollPane scrollPane = new JScrollPane(textArea);

                      JPanel contentPane = new JPanel();
                      contentPane.setLayout(new BorderLayout());
                      contentPane.setPreferredSize(new Dimension(400, 450));
                      contentPane.add(toolBar, BorderLayout.NORTH);
                      contentPane.add(scrollPane, BorderLayout.CENTER);
                      add(contentPane);
              }

              protected void addButtons(JToolBar toolBar)
              {
                      JButton button=null ;
                      button = new JButton();
                      button.setFont(new Font("Lucida Sans Regular",Font.PLAIN,8));
      button.setText("\u062a\u0641\u0627\u062d\u0020\u0623\u062d\u0645\u0631\u0020\u0643\u0628\u064a\u0631");
                      button.addActionListener(new ActionListener()
                      {

                      public void actionPerformed(ActionEvent e)
                      {
                              displayResult("Action for first button");
                      }
                      });


                      toolBar.add(button);
                      button = new JButton();
                      button.setFont(new Font("Lucida Sans Regular",Font.PLAIN,8));
      button.setText("\u05d6\u05d5\u0020\u05e9\u05e0\u05d4\u0020\u05d9\u05e4\u05d4\u0020\u0054\u0048\u0045\u0020\u0059\u0045\u0041\u0052\u0020\u0031\u0039\u0035\u0038");
                      button.addActionListener(new ActionListener()
                      {
                      public void actionPerformed(ActionEvent e)
                      {
                              displayResult("Action for second button");
                      }
                      });
                      toolBar.add(button);
                      button = new JButton();
                      button.setFont(new Font("Lucida Sans Regular",Font.PLAIN,8));
      button.setText("\u006c\u0069\u006d\u0065\u0020\u0069\u0073\u0020\u0067\u0072\u0065\u0065\u006e\u05d7\u05d5\u05de\u05d5\u05e1\u0020\u05d9\u05e7\u05e8");
                      button.setToolTipText("\u006c\u0069\u006d\u0065\u0020\u05d7\u05d5\u05de\u05d5\u05e1\u0020\u05d9\u05e7\u05e8\u0069\u0073\u0020\u0067\u0072\u0065\u0065\u006e");
                      button.addActionListener(new ActionListener()
                      {
                      public void actionPerformed(ActionEvent e)
                      {
                              displayResult("Action for third button");
                      }
                      });

                      toolBar.add(button);
                      button = new JButton();
      button.setText("\u062a\u0641\u0627\u062d\u0020\u0623\u062d\u0645\u0631\u0020\u0643\u0628\u064a\u0631");
                      button.setFont(new Font("Lucida Sans Regular",Font.PLAIN,8));
                      button.addActionListener(new ActionListener()
                      {
                      public void actionPerformed(ActionEvent e)
                      {
                              displayResult("Action for third button");
                      }
                      });


              }

              protected void displayResult(String actionDescription)
              {
                      textArea.append(actionDescription + newline);
              }
      }



      WorkAround:
      ======================================================================

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                leifs Leif Samuelsson (Inactive)
                Reporter:
                jbenavrasunw Jonathan Benavraham (Inactive)
              • Votes:
                0 Vote for this issue
                Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Imported:
                  Indexed: