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

JMenu and Window Resize Problem

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P4 P4
    • None
    • 1.1.5
    • client-libs
    • generic
    • solaris_2.5.1




      Name: el35337 Date: 05/28/98


      /*
       Class to test a flaky behavior of the Swing menus in conjunction with
       resizing a dialog from the left or top edge.

       To demonstrate the problem compile and run the class below and perform
       the following steps.

       1) Resize the dialog from the LEFT edge, making its width SMALLER
           by about 1 inch.

       2) Now pull down the "File" menu an notice that it displays the menu about
           1 inch to the right of where it should.

       3) Resize the dialog from the TOP edge, making its height SMALLER
           by about 1 inch.

       4) Now pull down the "File" menu again and notice that it displays
           the menu about 1 inch to the right and down of where it should.

       5) If you move the dialog the problem goes away and you can perform
           the test over again.

           Note that a similar problem occurs if you make the dialog
           larger using the LEFT or TOP resize handles except that the
           menu moves to the left and up.

           Also note that risizing the dialog from the left or bottom edge
           does not effect the menu display.
      */
      import java.awt.Dimension;
      import com.sun.java.swing.JDialog;
      import com.sun.java.swing.JMenuBar;
      import com.sun.java.swing.JMenu;
      import com.sun.java.swing.JMenuItem;


      public class TestDialog
          extends JDialog
          {
          public TestDialog()
              {
              final JMenuBar menuBar = new JMenuBar();
              setJMenuBar(menuBar);

              JMenu menu = menuBar.add(new JMenu("File"));
              menu.add(new JMenuItem("One"));
              menu.add(new JMenuItem("Two"));
              menu.add(new JMenuItem("Three"));
              }


          public static void main(
              final String[] args)
              {
              final JDialog dialog = new TestDialog();
              dialog.pack();
              dialog.setSize(new Dimension(400, 400));
              dialog.show();
              }
          }
      (Review ID: 32247)
      ======================================================================

            gsaab Georges Saab
            elarsen Erik Larsen (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: