public void showGotoDialog(final KeyEventBlocker blocker) {
    Dialog dialog = createGotoDialog();
    if (dialog == null) { // already visible
      // TODO:beep()
      return;
    }

    dialog.setVisible(true);
    gotoPanel.popupNotify(blocker);

    WindowAdapter winAdapt =
        new WindowAdapter() {
          public @Override void windowClosing(WindowEvent evt) {
            disposeGotoDialog();
          }

          public @Override void windowClosed(WindowEvent evt) {
            SwingUtilities.invokeLater(
                new Runnable() {
                  public void run() {
                    if (blocker != null) {
                      blocker.stopBlocking(false);
                    }
                    //                        Utilities.returnFocus();
                  }
                });
          }
        };
    dialog.addWindowListener(winAdapt);
  }
  public void showCustomizer(String preselectedCategory, String preselectedSubCategory) {

    Dialog dialog = project2Dialog.get(project);
    if (dialog != null) {
      dialog.setVisible(true);
      return;
    } else {
      SharedRubyProjectProperties uiProperties =
          createUiProperties(project, updateHelper, evaluator, refHelper, genFileHelper);
      Lookup context =
          Lookups.fixed(
              new Object[] {
                project,
                uiProperties,
                new SubCategoryProvider(preselectedCategory, preselectedSubCategory)
              });

      OptionListener listener = new OptionListener(project, uiProperties);
      dialog =
          ProjectCustomizer.createCustomizerDialog(
              getCustomizerFolderPath(), context, preselectedCategory, listener, null);
      dialog.addWindowListener(listener);
      dialog.setTitle(
          MessageFormat.format(
              NbBundle.getMessage(
                  BaseRubyCustomizerProvider.class, "LBL_Customizer_Title"), // NOI18N
              new Object[] {ProjectUtils.getInformation(project).getDisplayName()}));

      project2Dialog.put(project, dialog);
      dialog.setVisible(true);
    }
  }
示例#3
0
  void showWarning(Frame frame, String warning) {
    warningDialog = new Dialog(frame, "警告", true);
    warningDialog.setSize(200, 100);
    warningDialog.setLayout(new FlowLayout());
    warningDialog.setResizable(false);
    warningDialog.setLocationRelativeTo(frame);

    warningText = new Label(warning);
    warningButton = new Button("确认");

    warningDialog.add(warningText);
    warningDialog.add(warningButton);

    warningDialog.addWindowListener(
        new WindowAdapter() {
          public void windowClosing(WindowEvent e) {
            warningDialog.setVisible(false);
            warningDialog.dispose();
          }
        });

    warningButton.addKeyListener(
        new KeyAdapter() {
          public void keyPressed(KeyEvent e) {
            int keyCode = e.getKeyCode();

            if (keyCode == KeyEvent.VK_ENTER) {
              warningDialog.setVisible(false);
              warningDialog.dispose();
            }
          }
        });

    warningButton.addMouseListener(
        new MouseAdapter() {
          public void mouseClicked(MouseEvent e) {
            warningDialog.setVisible(false);
            warningDialog.dispose();
          }
        });

    warningDialog.setVisible(true);
  }
示例#4
0
  private void openDialog(String title, String string) {
    // TODO Auto-generated method stub
    Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
    Dimension dialogSize = new Dimension(200, 120);
    final Dialog dialog = new Dialog((Frame) getParent(), title);
    dialog.setSize(dialogSize);
    dialog.setLayout(null);
    dialog.setResizable(true);

    Label label = new Label(string);
    label.setSize(400, 50);
    label.setLocation(20, 30);
    dialog.add(label, "Center");

    Button enter = new Button("Return");
    enter.setSize(50, 25);
    enter.setLocation(75, 80);
    enter.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent arg0) {
            // TODO Auto-generated method stub
            dialog.dispose();
          }
        });
    dialog.add(enter);

    dialog.setLocation(
        (screenSize.width - dialogSize.width + 50) / 2,
        (screenSize.height - dialogSize.height + 40) / 2);
    dialog.setModal(true);
    dialog.addWindowListener(
        new WindowAdapter() {
          public void windowClosing(WindowEvent arg0) {
            // TODO Auto-generated method stub
            dialog.dispose();
          }
        });
    dialog.setVisible(true);
  }
 public static void main(String[] args) {
   Common.initRobot();
   final JButton start = new JButton("start");
   start.addActionListener(
       new ActionListener() {
         public void actionPerformed(ActionEvent ae) {
           act0();
           Common.robot.delay(500);
           act1();
           Common.robot.delay(1000);
           act2();
           //				Common.robot.delay(500);
           //				act3();
           //				Common.robot.delay(500);
           //				act4();
           //				Common.robot.delay(500);
           //				act5();
           //				Common.robot.delay(500);
           //				act6();
           //				Common.robot.delay(500);
           //				act7();
           start.setText("stopped");
         }
       });
   dashBoard.setLayout(new FlowLayout());
   dashBoard.add(start);
   dashBoard.addWindowListener(
       new WindowAdapter() {
         public void windowClosing(WindowEvent e) {
           System.exit(0);
         }
       });
   dashBoard.setLocation(new Point(10, 650));
   dashBoard.setSize(300, 70);
   dashBoard.setAlwaysOnTop(true);
   dashBoard.setVisible(true);
 }
示例#6
0
  public void makeTheWarning(
      int X,
      int Y,
      int width,
      int height,
      Color fg,
      Color bg,
      String title,
      String text,
      boolean oneLine,
      Frame frame) {

    Font warnFont = new java.awt.Font("SanSerif", Font.BOLD, 12);
    FontMetrics warnFontMetrics = getFontMetrics(warnFont);

    // Create Dialog window with modal blocking set to true.
    // Make final so inner class below can access it.

    final Dialog mww = new Dialog(frame, title, true);
    mww.setLayout(new BorderLayout());
    mww.setSize(width, height);
    mww.setLocation(X, Y);

    // Use Label for 1-line warning

    if (oneLine) {
      Label hT = new Label(text, Label.CENTER);
      hT.setForeground(fg);
      hT.setBackground(bg);
      hT.setFont(warnFont);
      mww.add("Center", hT);

      // Use TextArea for multiline warning

    } else {
      TextArea hT = new TextArea("", height, width, TextArea.SCROLLBARS_NONE);
      hT.setEditable(false);
      hT.setForeground(fg);
      hT.setBackground(bg); // no effect once setEditable (false)?
      hT.setFont(warnFont);
      mww.add("Center", hT);
      hT.appendText(text);
    }

    mww.setTitle(title);

    // Add dismiss button

    Panel botPanel = new Panel();
    botPanel.setBackground(Color.lightGray);
    Label label1 = new Label();
    Label label2 = new Label();

    Button dismissButton = new Button("Dismiss");
    botPanel.add(label1);
    botPanel.add(dismissButton);
    botPanel.add(label2);

    // Add inner class event handler for Dismiss button.  This must be
    // added to the dismissButton before botPanel is added to mww.

    dismissButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent ae) {
            mww.hide();
            mww.dispose();
          }
        });

    mww.add("South", botPanel);

    // Add window closing button (inner class)

    mww.addWindowListener(
        new WindowAdapter() {
          public void windowClosing(WindowEvent e) {
            mww.hide();
            mww.dispose();
          }
        });

    mww.show(); // Note that this show must come after all the above
    // additions; otherwise they are not added before the
    // window is displayed.
  }