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

Use new 1.2 APIs to allow PopupMenus for Modal Dialogs

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Duplicate
    • Icon: P4 P4
    • None
    • 1.2.2
    • client-libs
    • None

      Popup menus in Modal dialogs get cut off at the dialog border:

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



      public class TestJMenu05 extends JFrame implements ActionListener {
      /*************************************** Bug Description ***************************************/

      String[] strBugDesc = { "",
      "",
      "",
      "",
      "This TestCase tests the JDialog Component and JMenu Component",
      "**Problem** : JMenu menu items not fully visible when used in a JDialog",
      "",
      "Steps to reproduce :",
      "1. Click on menu 'Does Nothing JMenuItem'. -- this works properly when in a JFrame.",
      "2. Click on 'Show the Dialog' button. -- this brings up a dialog.",
      "3. Click on menu 'Does Nothing JMenuItem' in the dialog. -- All the menuitems are not visible.",
      "4. Increase the size of the the dialog to more than the size of the menuitems when dropped down.",
      "5. Click on menu 'Does Nothing JMenuItem' in the dialog. -- Now all the menuitems are visible.",
      "",
      "Pass/Fail Criteria : ",
      "Pass -- Click on menu 'Does Nothing JMenuItem' in the dialog before resizing the dialog. -- All the menuitems should be visible.",
      "",
      "",
      "",
      ""};
        /*************************************** Bug Description ***************************************/

      Container content;
      JPanel panel;
      JDialog dialog;
      JButton bn;

      TestJMenu05(String[] args) {

      displayBugDesc();

      content = getContentPane();

      content.setLayout(new BorderLayout());

      addWindowListener(new WindowAdapter() {

      public void windowClosing(WindowEvent event){

      System.exit(0);

      }

      }

      );

      panel = new JPanel();

      panel.setLayout(new FlowLayout());


      panel.add(bn = new JButton("Show the Dialog"));
      bn.addActionListener(this);

      panel.add(getMyMenuBar());

      content.add("Center", panel);
      pack();
      show();
      }


      public void actionPerformed(ActionEvent e) {
      if(e.getActionCommand().equals("Show the Dialog")) {
      dialog = new JDialog(TestJMenu05.this, "Testing the Dailog", true);
      dialog.getContentPane().add("South", new JButton("Simple Button in the Dialog. Does Nothing!!"));
      dialog.getContentPane().add("North", getMyMenuBar());
      dialog.setLocationRelativeTo(null);
      dialog.pack();
      dialog.show();
      }
      }

      public JMenuBar getMyMenuBar() {
      JMenuBar menubar;
      JMenu menu;
      JMenuItem menuitem;
      JCheckBoxMenuItem cbmItem;
      JRadioButtonMenuItem rbmItem;

      menubar = new JMenuBar();
      menu = new JMenu("Does nothing JMenuItem");
      menu.setMnemonic('M');
      for(int i = 0; i < 10; i ++ ) {
      menuitem = new JMenuItem("JMenuItem" + i);
      menuitem.setMnemonic('0' + i);
      menu.add(menuitem);
      }
      menubar.add(menu);
      return menubar;
      }



      public void displayBugDesc() {
      int n = strBugDesc.length;
      System.out.println("/******************************* Bug Description and Comments *******************************/");
      System.out.println();
      for(int i = 0; i < n; i ++) {
      System.out.println(strBugDesc[i]);
      }
      System.out.println();
      System.out.println("/******************************* Bug Description and Comments *******************************/");
      }



      // Main funtion
      public static void main(String[] args) {
      TestJMenu05 TestJMenu05 = new TestJMenu05(args);
      }
      }

            gsaab Georges Saab
            gsaab Georges Saab
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: