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

modal Dialogs triggered by MenuShortcuts do not allow TextField input

    XMLWordPrintable

    Details

    • Subcomponent:
    • CPU:
      x86, sparc
    • OS:
      solaris_7, windows_nt

      Description



      Name: diC59631 Date: 11/11/97


      create a simple modal dialog box with a textfield contained within it.

      create a menuitem along with a shortcut that will spawn this modal dialog.

      try to type in the dialog's textfield.

      here is some sample code:
      //*********************************
      import java.awt.*;
      import java.awt.event.*;

      public class testModal extends Frame implements ActionListener
      {
        private MenuItem makeDialog;
        private IndentDialog indent;

        public static void main(String[] args)
        {
          testModal thisapp = new testModal();
        }

        public testModal()
        {
          super("test modality");
          MenuBar mb = new MenuBar();
          Menu test = new Menu("test");
          test.add(makeDialog = new MenuItem("makeDialog", new MenuShortcut('m')));
          mb.add(test);
          setMenuBar(mb);

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

          makeDialog.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
              indent = new IndentDialog(this, "", true);
            }
          });

          setBounds(100, 100, 200, 100);
          setVisible(true);
        }
      }
      //****************************************
      public class IndentDialog extends Dialog implements ActionListener
      {
        TextField indentSize;
        Label pixels;
        Button ok, cancel;
        int size;

      public IndentDialog(Frame f, String title, boolean modal)
      {
      super(f,title,modal);
      setLayout(new BorderLayout());
      setResizable(false);
      setSize(200,100);
      setLocation(300,300);
      Panel buttons = new Panel();
      buttons.setLayout(new FlowLayout(FlowLayout.CENTER));
      buttons.add(ok= new Button("OK"));
      buttons.add(cancel = new Button("Cancel"));

      Panel topPanel = new Panel();
      topPanel.setLayout(new FlowLayout(FlowLayout.CENTER));
      topPanel.add(pixels = new Label("Pixels:", Label.CENTER));
      topPanel.add(indentSize= new TextField(10));
      add("Center", topPanel);
      add("South", buttons);

      size = 0;
      this.addWindowListener(new WinAdapter(false, false));
      ok.addActionListener(this);
      cancel.addActionListener(this);
      }

      public void actionPerformed(ActionEvent e)
      {
      if(e.getActionCommand() == "OK")
      {
      if(indentSize.getText().length() <= 0) return;
      try
      {
      size = (new Integer(indentSize.getText())).intValue();
      }
      catch(NumberFormatException ex)
      {
      indentSize.setText("integral values only");
      return;
      }
      indentSize.setText("");
      setVisible(false);
      dispose();
      }
      if(e.getActionCommand() == "Cancel")
      {
      size = -1;
      indentSize.setText("");
      setVisible(false);
      dispose();
      }
      }
      public int getIndentSize() {return size;}
      }
      (Review ID: 19774)
      ======================================================================
      Another report: (see ATTACHMENTS for code example)

      I have modal dialog containing "OK"/"Cancel" buttons
      together with TextField. This dialog is connected
      with menu item. When I choose this menu item with mouse or keyboard,
      dialog works, bu if I use shortcut, input to TextField locks, and
      beeps are sent to speaker. When I recompiled
      my classes with jdk1.1.3/1.1.2/1.1.1 everithing works
      perfectly.
      2nd: I cannot use comma,+,- (i.e. not-letter symbols)
      for menu shortcuts.

      brian.klock@eng 1997-11-17
      ======================================================================

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              son Oleg Sukhodolsky (Inactive)
              Reporter:
              dindrigo Daniel Indrigo (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: