示例#1
1
  // --------------------------------actionHost---------------------------------
  private void actionHost() {
    if (oParty == null) {
      JOptionPane.showMessageDialog(frame, "Make a party before trying to connect.");
      return;
    }

    JFileChooser oFC = new JFileChooser(DEFAULT_MAP_DIRECTORY);
    int nReturn = oFC.showOpenDialog(frame);

    if (nReturn == JFileChooser.CANCEL_OPTION) {
      return;
    }

    int nPort = Integer.parseInt((String) (DialogManager.show(DialogManager.HOST, frame)));

    JDialog dlgBox = (JDialog) (DialogManager.show(DialogManager.WAITING_FOR_CONN, frame));
    dlgBox.pack();
    try {
      oConn.host(nPort);
    } catch (IOException e) {
      JOptionPane.showMessageDialog(frame, e.getMessage(), "Error!", JOptionPane.ERROR_MESSAGE);
      frame.repaint();
      return;
    }
    dlgBox.setVisible(false);
    echo("Connected to opponent!");

    tConn = new Thread(oConn, "conn");
    tConn.start();
    tMain = new Thread(this, "main");
    tMain.start();

    try {
      oMap.loadMap(oFC.getSelectedFile());
      oConn.send("loadmap", oFC.getName(oFC.getSelectedFile()));
    } catch (Exception e) {
      e.printStackTrace();
      System.exit(-1);
    }
  }
  /**
   * @param editor
   * @param idDialog
   * @param dialog
   * @param title
   */
  public static void setDialogVisible(
      @Nullable Editor editor, String idDialog, JDialog dialog, String title) {
    Point location = null;

    if (editor != null) {
      Point caretLocation = editor.visualPositionToXY(editor.getCaretModel().getVisualPosition());
      SwingUtilities.convertPointToScreen(caretLocation, editor.getComponent());

      String[] position = UtilsPreferences.getDialogPosition(idDialog).split("x");
      if (!(position[0].equals("0") && position[1].equals("0"))) {
        location = new Point(Integer.parseInt(position[0]), Integer.parseInt(position[1]));
      }
    }

    if (location == null) {
      // Center to screen
      dialog.setLocationRelativeTo(null);
    } else {
      dialog.setLocation(location.x, location.y);
    }

    dialog.setTitle(title);
    dialog.pack();
    dialog.setVisible(true);
  }
示例#3
0
 public char[] askPassword() {
   char[] password = null;
   final JDialog dlg = new JDialog(frm, "Password", true);
   final JPasswordField jpf = new JPasswordField(15);
   final JButton[] btns = {new JButton("Enter"), new JButton("Cancel")};
   for (int i = 0; i < btns.length; i++) {
     btns[i].addActionListener(
         new ActionListener() {
           public void actionPerformed(ActionEvent e) {
             dlg.setVisible(false);
           }
         });
   }
   Object[] prts = new Object[] {"Please input a password:"******"Invalid password, passwords must be " + PASSWORD_MIN + " characters long");
     System.exit(1);
   }
   return password;
 }
  /** Initialise. */
  public synchronized void initialise() {

    // wait until application is properly initialised
    while (applicationService == null) {
      // idle in this thread
      try {
        this.wait(6000);
      } catch (InterruptedException e) {
        logger.warn("e.getMessage() = " + e.getMessage());
      }

      if (applicationService != null && applicationService.getErrorLoggerService() != null) {
        this.applicationService.getErrorLoggerService().registerListener(this);
      }
    }

    // set LNF first to avoid component UI errors
    LookAndFeelUtils.setDefaultLNF();

    errorPane = new JXErrorPane();
    errorPane.setPreferredSize(new Dimension(400, 300));
    errorPane.setIcon(ImageUtils.getIcon(ImageUtils.IconName.WARNING_ICON_48));
    errorPane.setErrorReporter(this);
    errorDialog = JXErrorPane.createDialog(null, errorPane);
    errorDialog.setDefaultCloseOperation(JDialog.HIDE_ON_CLOSE);
    errorDialog.pack();
  }
  /*
   * The following method creates the color chooser dialog box
   */
  public void createColorDialog() {
    colorDialog = new JDialog(this, new String("Choose a color"), true);
    colorDialog.getContentPane().add(createColorPicker(), BorderLayout.CENTER);

    JButton okButton = new JButton("OK");

    // This class is used to create a special ActionListener for
    //    the ok button
    class ButtonListener implements ActionListener {
      /*
       * This method is called whenever the ok button is clicked
       */
      public void actionPerformed(ActionEvent event) {
        currentChoice.changeColor(color_panel.getColor());
        currentChoice.repaint();
        fontColor = color_panel.getColor();
        colorDialog.hide();
      } // end actionPerformed method
    }
    ActionListener listener = new ButtonListener();
    okButton.addActionListener(listener);

    // Add the four font control panels to one big panel using
    //  a grid layout
    JPanel buttonPanel = new JPanel();

    buttonPanel.add(okButton);

    // Add the button panel to the content pane of the ColorDialogue
    colorDialog.getContentPane().add(buttonPanel, BorderLayout.SOUTH);

    colorDialog.pack();
  }
示例#6
0
  static void tell(String question, String btnText) {
    final JDialog d = new JDialog();
    d.setLocationRelativeTo(null);
    JPanel bpane = new JPanel(new FlowLayout());
    JLabel l = new JLabel(question);

    JPanel cp = (JPanel) d.getContentPane();

    cp.setLayout(new FlowLayout());
    cp.add(l, BorderLayout.CENTER);
    cp.add(bpane, BorderLayout.SOUTH);

    JButton b1 = new JButton("OK");
    bpane.add(b1);

    d.pack();

    d.setVisible(true);

    b1.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            ans = ((JButton) e.getSource()).getText();
            d.dispose();
          }
        });
  }
 /** Show the filter dialog */
 public void showDialog() {
   empty_border = new EmptyBorder(5, 5, 0, 5);
   indent_border = new EmptyBorder(5, 25, 5, 5);
   include_panel =
       new ServiceFilterPanel("Include messages based on target service:", filter_include_list);
   exclude_panel =
       new ServiceFilterPanel("Exclude messages based on target service:", filter_exclude_list);
   status_box = new JCheckBox("Filter messages based on status:");
   status_box.addActionListener(this);
   status_active = new JRadioButton("Active messages only");
   status_active.setSelected(true);
   status_active.setEnabled(false);
   status_complete = new JRadioButton("Complete messages only");
   status_complete.setEnabled(false);
   status_group = new ButtonGroup();
   status_group.add(status_active);
   status_group.add(status_complete);
   if (filter_active || filter_complete) {
     status_box.setSelected(true);
     status_active.setEnabled(true);
     status_complete.setEnabled(true);
     if (filter_complete) {
       status_complete.setSelected(true);
     }
   }
   status_options = new JPanel();
   status_options.setLayout(new BoxLayout(status_options, BoxLayout.Y_AXIS));
   status_options.add(status_active);
   status_options.add(status_complete);
   status_options.setBorder(indent_border);
   status_panel = new JPanel();
   status_panel.setLayout(new BorderLayout());
   status_panel.add(status_box, BorderLayout.NORTH);
   status_panel.add(status_options, BorderLayout.CENTER);
   status_panel.setBorder(empty_border);
   ok_button = new JButton("Ok");
   ok_button.addActionListener(this);
   cancel_button = new JButton("Cancel");
   cancel_button.addActionListener(this);
   buttons = new JPanel();
   buttons.setLayout(new FlowLayout());
   buttons.add(ok_button);
   buttons.add(cancel_button);
   panel = new JPanel();
   panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
   panel.add(include_panel);
   panel.add(exclude_panel);
   panel.add(status_panel);
   panel.add(buttons);
   dialog = new JDialog();
   dialog.setTitle("SOAP Monitor Filter");
   dialog.setContentPane(panel);
   dialog.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
   dialog.setModal(true);
   dialog.pack();
   Dimension d = dialog.getToolkit().getScreenSize();
   dialog.setLocation((d.width - dialog.getWidth()) / 2, (d.height - dialog.getHeight()) / 2);
   ok_pressed = false;
   dialog.show();
 }
示例#8
0
  public JDialog showProgressDialog(
      JDialog parent, String title, String message, boolean includeCancelButton) {
    fileSearchCancelled = false;
    final JDialog prog;
    JProgressBar bar = new JProgressBar(SwingConstants.HORIZONTAL);
    JButton cancel = new JButton(Globals.lang("Cancel"));
    cancel.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent event) {
            fileSearchCancelled = true;
            ((JButton) event.getSource()).setEnabled(false);
          }
        });
    prog = new JDialog(parent, title, false);
    bar.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
    bar.setIndeterminate(true);
    if (includeCancelButton) {
      prog.add(cancel, BorderLayout.SOUTH);
    }
    prog.add(new JLabel(message), BorderLayout.NORTH);
    prog.add(bar, BorderLayout.CENTER);
    prog.pack();
    prog.setLocationRelativeTo(null); // parent);
    // SwingUtilities.invokeLater(new Runnable() {
    //    public void run() {
    prog.setVisible(true);
    //    }
    // });
    return prog;
  }
示例#9
0
  public void showTaskDialog(final Task selectedValue) {

    final JDialog taskForm =
        new JDialog(this, "Create new task", Dialog.ModalityType.APPLICATION_MODAL);
    JPanel content = new JPanel(new GridLayout(3, 1));
    final JPanel namePanel = new JPanel(new FlowLayout());
    namePanel.add(new JLabel("Name:"));
    final JTextField taskName =
        new JTextField(selectedValue == null ? "" : selectedValue.getName(), 30);
    namePanel.add(taskName);
    content.add(namePanel);

    final JPanel descPanel = new JPanel(new FlowLayout());
    descPanel.add(new JLabel("Description:"));
    final JTextArea taskDesc =
        new JTextArea(selectedValue == null ? "" : selectedValue.getDescription(), 5, 30);
    descPanel.add(taskDesc);
    content.add(descPanel);

    JPanel btnPanel = new JPanel(new FlowLayout());

    JButton cancel = new JButton("Cancel");
    cancel.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            taskForm.dispose();
          }
        });
    btnPanel.add(cancel);

    JButton save = new JButton("Save");
    save.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            if (selectedValue == null) {
              Task task = new Task(taskName.getText());
              task.setDescription(taskDesc.getText());
              logger.info("Create task: " + task);
              controller.addTask(task);
            } else {
              selectedValue.setName(taskName.getText());
              selectedValue.setDescription(taskDesc.getText());
              logger.info("Update task: " + selectedValue);
              controller.editTask(selectedValue);
            }
            taskForm.dispose();
          }
        });
    btnPanel.add(save);

    content.add(btnPanel);

    taskForm.getContentPane().add(content);
    taskForm.setLocationRelativeTo(null);
    taskForm.pack();
    taskForm.setVisible(true);
  }
示例#10
0
 public JDialog createFileChooserDialog(JFileChooser jfilechooser, String s, Container container) {
   JDialog jdialog = new JDialog(frame, s, true);
   jdialog.setDefaultCloseOperation(2);
   jdialog.add(jfilechooser);
   jdialog.pack();
   jdialog.setLocationRelativeTo(container);
   return jdialog;
 }
示例#11
0
  public int showDialog() {
    panel = new JPanel(new GridBagLayout());

    double lower = Double.NEGATIVE_INFINITY;
    double upper = Double.POSITIVE_INFINITY;

    if (parameter.isZeroOne) {
      lower = 0.0;
      upper = 1.0;
    } else if (parameter.isNonNegative) {
      lower = 0.0;
    }

    panel = new JPanel(new GridBagLayout());

    setupComponents();

    JOptionPane optionPane =
        new JOptionPane(
            panel, JOptionPane.PLAIN_MESSAGE, JOptionPane.OK_CANCEL_OPTION, null, null, null);
    optionPane.setBorder(new EmptyBorder(12, 12, 12, 12));

    final JDialog dialog = optionPane.createDialog(frame, "Linked Parameter Setup");

    priorSettingsPanel.setDialog(dialog);
    priorSettingsPanel.setParameter(parameter);

    if (OSType.isMac()) {
      dialog.setMinimumSize(new Dimension(dialog.getBounds().width, 300));
    } else {
      Toolkit tk = Toolkit.getDefaultToolkit();
      Dimension d = tk.getScreenSize();
      if (d.height < 700 && panel.getHeight() > 450) {
        dialog.setSize(new Dimension(panel.getWidth() + 100, 550));
      } else {
        // setSize because optionsPanel is shrunk in dialog
        dialog.setSize(new Dimension(panel.getWidth() + 100, panel.getHeight() + 100));
      }

      //            System.out.println("panel width = " + panel.getWidth());
      //            System.out.println("panel height = " + panel.getHeight());
    }

    dialog.pack();
    dialog.setResizable(true);
    dialog.setVisible(true);

    int result = JOptionPane.CANCEL_OPTION;
    Integer value = (Integer) optionPane.getValue();
    if (value != null && value != -1) {
      result = value;
    }

    return result;
  }
示例#12
0
  public DatePicker(JFrame parent) {
    d = new JDialog();
    d.setModal(true);
    String[] header = {"Sun", "Mon", "Tue", "Wed", "Thur", "Fri", "Sat"};
    JPanel p1 = new JPanel(new GridLayout(7, 7));
    p1.setPreferredSize(new Dimension(430, 120));

    for (int x = 0; x < button.length; x++) {
      final int selection = x;
      button[x] = new JButton();
      button[x].setFocusPainted(false);
      button[x].setBackground(Color.white);
      if (x > 6)
        button[x].addActionListener(
            new ActionListener() {
              public void actionPerformed(ActionEvent ae) {
                day = button[selection].getActionCommand();
                d.dispose();
              }
            });
      if (x < 7) {
        button[x].setText(header[x]);
        button[x].setForeground(Color.red);
      }
      p1.add(button[x]);
    }
    JPanel p2 = new JPanel(new GridLayout(1, 3));
    JButton previous = new JButton("<< Previous");
    previous.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent ae) {
            month--;
            displayDate();
          }
        });
    p2.add(previous);
    p2.add(l);
    JButton next = new JButton("Next >>");
    next.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent ae) {
            month++;
            displayDate();
          }
        });
    p2.add(next);
    d.add(p1, BorderLayout.CENTER);
    d.add(p2, BorderLayout.SOUTH);
    d.pack();
    d.setLocationRelativeTo(parent);
    displayDate();
    d.setVisible(true);
  }
示例#13
0
  public int showDialog() {

    options = new OptionsPanel(6, 6);

    options.addComponent(autoScaleCheck);

    JPanel panel = new JPanel();
    panel.setLayout(new FlowLayout());
    panel.add(fromLabel);
    panel.add(fromNumberField);
    panel.add(toLabel);
    panel.add(toNumberField);
    options.addComponent(panel);

    JPanel panel1 = new JPanel();
    panel1.setLayout(new FlowLayout());
    panel1.add(new JLabel("Width from:"));
    panel1.add(fromWidthField);
    panel1.add(new JLabel("to:"));
    panel1.add(toWidthField);
    options.addComponent(panel1);

    JOptionPane optionPane =
        new JOptionPane(
            options, JOptionPane.QUESTION_MESSAGE, JOptionPane.OK_CANCEL_OPTION, null, null, null);
    optionPane.setBorder(new EmptyBorder(12, 12, 12, 12));

    final JDialog dialog = optionPane.createDialog(frame, "Setup colour range");
    dialog.pack();

    autoScaleCheck.addItemListener(
        new ItemListener() {
          public void itemStateChanged(ItemEvent e) {
            boolean enabled = !autoScaleCheck.isSelected();
            fromLabel.setEnabled(enabled);
            fromNumberField.setEnabled(enabled);
            toLabel.setEnabled(enabled);
            toNumberField.setEnabled(enabled);
          }
        });

    dialog.setVisible(true);

    int result = JOptionPane.CANCEL_OPTION;
    Integer value = (Integer) optionPane.getValue();
    if (value != null && value.intValue() != -1) {
      result = value.intValue();
    }

    return result;
  }
示例#14
0
  /**
   * Utility method to put the given panel in a JDialog. You'll have to show it on your own.
   *
   * @param panel the panel to put in a dialog
   * @param owner the JFrame that owns the dialog. You can pass null.
   * @param dialogTitle the title for the dialog
   * @param iconPath the path to the dialog's icon, such as foo.png
   * @param width the dialog's width. Pass -1 to pack().
   * @param height the dialog's height. Pass -1 to pack().
   * @return the JDialog the panel is in
   */
  public static JDialog putPanelInDialog(
      JPanel panel, JFrame owner, String dialogTitle, String iconPath, int width, int height) {
    JDialog dialog = new JDialog(owner, dialogTitle, true); // boolean means modality

    dialog.add(panel);
    dialog.setIconImage(ImageManager.createImageIcon(iconPath).getImage());
    if (width < 0 && height < 0) dialog.pack();
    else dialog.setSize(width, height);
    dialog.setResizable(false);
    if (owner != null) Utils.centerComponent(dialog, owner);
    else dialog.setLocationRelativeTo(null);

    return dialog;
  }
示例#15
0
 public void actionPerformed(ActionEvent evt) {
   JDialog parent = GUIUtilities.getParentDialog(ColorWellButton.this);
   JDialog dialog;
   if (parent != null) {
     dialog = new ColorPickerDialog(parent, jEdit.getProperty("colorChooser.title"), true);
   } else {
     dialog =
         new ColorPickerDialog(
             JOptionPane.getFrameForComponent(ColorWellButton.this),
             jEdit.getProperty("colorChooser.title"),
             true);
   }
   dialog.pack();
   dialog.setVisible(true);
 }
示例#16
0
  public static JDialog createDialog(JComponent parent, OWLEditorKit editorKit) {
    JFrame parentFrame = (JFrame) SwingUtilities.getAncestorOfClass(JFrame.class, parent);
    final JDialog dialog = new JDialog(parentFrame, "Search", Dialog.ModalityType.MODELESS);

    final SearchDialogPanel searchDialogPanel = new SearchDialogPanel(editorKit);
    searchDialogPanel.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2));

    searchDialogPanel
        .getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT)
        .put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), "CLOSE_DIALOG");
    searchDialogPanel
        .getActionMap()
        .put(
            "CLOSE_DIALOG",
            new AbstractAction() {
              @Override
              public void actionPerformed(ActionEvent e) {
                dialog.setVisible(false);
              }
            });

    searchDialogPanel
        .getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT)
        .put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), "CLOSE_DIALOG_WITH_ENTER");
    searchDialogPanel
        .getActionMap()
        .put(
            "CLOSE_DIALOG_WITH_ENTER",
            new AbstractAction() {
              @Override
              public void actionPerformed(ActionEvent e) {
                dialog.setVisible(false);
                searchDialogPanel.selectEntity();
              }
            });

    dialog.setContentPane(searchDialogPanel);
    dialog.setResizable(true);
    dialog.pack();
    dialog.addWindowListener(
        new WindowAdapter() {
          @Override
          public void windowOpened(WindowEvent e) {
            searchDialogPanel.searchField.requestFocusInWindow();
          }
        });
    return dialog;
  }
示例#17
0
  public void runCalculatorDialog(MouseEvent e) {
    if (calculatorDialog == null) {
      JFrame frame = null;
      Container container = getTopLevelAncestor();

      if (container instanceof JFrame) {
        frame = (JFrame) container;
      }

      calculatorDialog = new JDialog(frame, "Rechner", true);
      calculator = new Calculator();
      calculator.getOKButton().addActionListener(this);
      calculatorDialog.getContentPane().add(calculator);
      calculatorDialog.pack();
    }

    // Set calculator's init value

    Money money = getValue();

    if (money != null) {
      calculator.setValue(money.getValue());
    } else {
      calculator.setValue(0.0);
    }

    // calculate POP (point of presentation)

    Point point = ((JComponent) e.getSource()).getLocationOnScreen();
    int x = point.x + e.getX();
    int y = point.y + e.getY();

    // ensure that it does not exceed the screen limits

    Dimension screenDim = Toolkit.getDefaultToolkit().getScreenSize();
    Dimension dim = calculatorDialog.getPreferredSize();
    if (x + dim.width >= screenDim.width) {
      x = screenDim.width - dim.width - 1;
    }
    if (y + dim.height >= screenDim.height) {
      y = screenDim.height - dim.height - 1;
    }

    // make it visible at wanted location

    calculatorDialog.setLocation(x, y);
    calculatorDialog.show();
  }
示例#18
0
 /** Create and show the gui */
 public void showDialog() {
   if (dialog == null) {
     JFrame parentFrame = persistenceManager.getIdv().getIdvUIManager().getFrame();
     dialog = new JDialog(parentFrame, "Loading Bundle");
     if (dialogTitle != null) {
       dialog.setTitle("Loading Bundle: " + dialogTitle);
     }
     dialog.getContentPane().add(contents);
   }
   dialog.pack();
   Point center = GuiUtils.getLocation(null);
   if (persistenceManager.getIdv().okToShowWindows()) {
     dialog.setLocation(20, 20);
     dialog.setVisible(true);
   }
 }
示例#19
0
  public void setPanel(Parameters pp, String s) {
    JPanel buttonsPanel = new JPanel();
    okButton = new JButton("确定");
    okButton.addActionListener(this);

    dialog = new JDialog(this, s + " 参数选择", true);

    Container contentPane = getContentPane();
    Container dialogContentPane = dialog.getContentPane();

    dialogContentPane.add(pp, BorderLayout.CENTER);
    dialogContentPane.add(buttonsPanel, BorderLayout.SOUTH);
    dialog.pack();
    buttonsPanel.add(okButton);
    dialog.setLocation(50, 330);
    dialog.show();
  }
示例#20
0
  public static Map[] showOpenMapDialog(final JFrame owner) throws IOException {
    final JFileChooser ch = new JFileChooser();
    if (config.getFile("mapLastOpenDir") != null) {
      ch.setCurrentDirectory(config.getFile("mapLastOpenDir"));
    }
    ch.setDialogType(JFileChooser.OPEN_DIALOG);
    ch.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
    if (ch.showOpenDialog(MainFrame.getInstance()) != JFileChooser.APPROVE_OPTION) {
      return null;
    }
    final File dir = ch.getSelectedFile();
    config.set("mapLastOpenDir", dir);
    final String[] maps = dir.list(FILTER_TILES);
    for (int i = 0; i < maps.length; ++i) {
      maps[i] = maps[i].substring(0, maps[i].length() - MapIO.EXT_TILE.length());
    }
    final JDialog dialog = new JDialog(owner, Lang.getMsg("gui.chooser"));
    dialog.setModal(true);
    dialog.setLocationRelativeTo(null);
    dialog.setLayout(new BorderLayout());

    final JList list = new JList(maps);
    final JButton btn = new JButton(Lang.getMsg("gui.chooser.Ok"));

    btn.addActionListener(
        new AbstractAction() {
          @Override
          public void actionPerformed(final ActionEvent e) {
            if (list.getSelectedValue() != null) {
              dialog.setVisible(false);
            }
          }
        });

    dialog.add(new JScrollPane(list), BorderLayout.CENTER);
    dialog.add(btn, BorderLayout.SOUTH);
    dialog.pack();
    dialog.setVisible(true);
    dialog.dispose();

    Map[] loadedMaps = new Map[list.getSelectedIndices().length];
    for (int i = 0; i < list.getSelectedIndices().length; i++) {
      loadedMaps[i] = MapIO.loadMap(dir.getPath(), (String) list.getSelectedValues()[i]);
    }
    return loadedMaps;
  }
  /**
   * Show tracker
   *
   * @param parent GUI parent widget
   */
  public final void show(final Component parent) {
    Frame frame = (Frame) SwingUtilities.getAncestorOfClass(Frame.class, parent);

    dialog.getContentPane().setLayout(new BorderLayout());

    label = new JLabel(START_HTML + labelText + END_HTML);

    JPanel labelPanel = new JPanel();
    labelPanel.setLayout(new BorderLayout());
    labelPanel.setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20));
    labelPanel.add(label, BorderLayout.CENTER);

    dialog.getContentPane().add(labelPanel, BorderLayout.CENTER);

    dialog.pack();
    Windows.centerOnScreen(dialog);
    dialog.show();
  }
示例#22
0
 private void prepareDialog() {
   JButton cancel = new JButton("Cancel");
   cancel.addActionListener(
       new ActionListener() {
         @Override
         public void actionPerformed(ActionEvent actionEvent) {
           dialog.setVisible(false);
         }
       });
   JPanel bp = new JPanel(new FlowLayout(FlowLayout.RIGHT));
   bp.add(cancel);
   JPanel p = new JPanel(new GridLayout(1, 0, 15, 15));
   p.setBorder(BorderFactory.createEmptyBorder(15, 15, 15, 15));
   p.add(new JButton(chooseFileAction));
   p.add(new JButton(harvestAction));
   dialog.getContentPane().add(p, BorderLayout.CENTER);
   dialog.getContentPane().add(bp, BorderLayout.SOUTH);
   dialog.pack();
 }
示例#23
0
  /**
   * Uses a JEditorPane to open the given URL in a dialog
   *
   * @param url the url to load
   * @param title the title of the dialog
   * @param frame the parent frame
   * @param visible true if you want the dialog to be visible, false if you want it to be invisible
   *     to user
   * @param iconPath the path to the image icon for the dialog.
   */
  public static void openURLinDialog(
      String url, String title, String iconPath, JFrame frame, boolean visible) {
    // create panel with page in it
    final int WIDTH = 400;
    final int HEIGHT = 300;
    JPanel webView = createEditorPane(url, WIDTH, HEIGHT);

    // put it in a dialog
    JDialog dialog = new JDialog(frame);
    dialog.setTitle(title);
    dialog.setIconImage(GUI.createImageIcon(iconPath).getImage());
    dialog.setContentPane(webView);
    dialog.pack();
    dialog.setResizable(false);
    dialog.setModal(true);
    Utils.centerComponent(dialog, frame);

    // open it
    dialog.setVisible(visible);
  }
示例#24
0
  /**
   * Sets up the given dialog's content pane by setting its border to provide a good default spacer,
   * and setting the content pane to the given components.
   *
   * @param aDialog the dialog to setup, cannot be <code>null</code>;
   * @param aCenterComponent the component that should appear at the center of the dialog;
   * @param aButtonPane the component that should appear at the bottom of the dialog
   * @param defaultButton the default button for this dialog; can be null for "none".
   * @see javax.swing.JRootPane#setDefaultButton(javax.swing.JButton)
   */
  public static void setupDialogContentPane(
      final JDialog aDialog,
      final Component aCenterComponent,
      final Component aButtonPane,
      final JButton defaultButton) {
    final JPanel contentPane = new JPanel(new BorderLayout());
    contentPane.setBorder(
        BorderFactory.createEmptyBorder(
            DIALOG_PADDING,
            DIALOG_PADDING, //
            DIALOG_PADDING,
            DIALOG_PADDING));

    contentPane.add(aCenterComponent, BorderLayout.CENTER);
    contentPane.add(aButtonPane, BorderLayout.PAGE_END);

    aDialog.setContentPane(contentPane);
    aDialog.getRootPane().setDefaultButton(defaultButton);
    aDialog.pack();
  }
示例#25
0
  public boolean showDialog(String title) {

    JOptionPane optionPane =
        new JOptionPane(
            optionPanel,
            JOptionPane.PLAIN_MESSAGE,
            JOptionPane.OK_CANCEL_OPTION,
            null,
            new String[] {"Run", "Quit"},
            "Run");
    optionPane.setBorder(new EmptyBorder(12, 12, 12, 12));

    final JDialog dialog = optionPane.createDialog(frame, title);
    // dialog.setResizable(true);
    dialog.pack();

    dialog.setVisible(true);

    return (optionPane.getValue() != null ? optionPane.getValue().equals("Run") : false);
  }
示例#26
0
    public DialogPopupWrapper(Component owner, Component content, int x, int y) {
      if (!owner.isShowing()) {
        throw new IllegalArgumentException("Popup owner must be showing");
      }

      final Window wnd =
          owner instanceof Window ? (Window) owner : SwingUtilities.getWindowAncestor(owner);
      if (wnd instanceof Frame) {
        myDialog = new JDialog((Frame) wnd, false);
      } else {
        myDialog = new JDialog((Dialog) wnd, false);
      }

      myDialog.getContentPane().setLayout(new BorderLayout());
      myDialog.getContentPane().add(content, BorderLayout.CENTER);

      myDialog.setUndecorated(true);
      myDialog.pack();
      myDialog.setLocation(x, y);
    }
示例#27
0
  @Override
  protected void fireActionPerformed(ActionEvent event) {
    try {
      this.setSelected(true);

      // create the dialog if this has not been done yet.
      if (this.dialog == null) {
        // Get the top level ancestor as parent for the new dialog.
        // This ensures that on Mac OS X the global menu bar remains
        // visible while the dialog is open.
        final Container parent = this.getTopLevelAncestor();
        dialog =
            JColorChooser.createDialog(
                parent,
                colorChooserTitle,
                true, // modal
                colorChooser,
                this, // OK button handler
                null); // no CANCEL button handler
        dialog.pack();
        dialog.setResizable(false);
      }

      // show the dialog
      colorChooser.setColor(color);
      dialog.setVisible(true);

      /* A simpler option that is displaying the ugly preview panel:
      Color newColor = JColorChooser.showDialog(this.getTopLevelAncestor(),
              colorChooserTitle, color);
      if (newColor != null){
          // only set color and fire an event when user did not cancel.
          this.setColor(newColor);
          super.fireActionPerformed(event);
      }*/
    } catch (Exception e) {
    } finally {
      this.setSelected(false);
    }
  }
示例#28
0
  private void mouseClicked_searchSource() {

    SourceSearchPanel ssp = new SourceSearchPanel();

    Point p = getLocation();
    orgSearchDialog.setLocation(p.x + 50, p.y + 50);

    ssp.addActionListener(
        new ActionListener() {

          public void actionPerformed(ActionEvent e) {

            Source source = (Source) e.getSource();

            setToAddress(source.getName() + " <" + source.getEmail() + ">");
            orgSearchDialog.dispose();
          }
        });

    orgSearchDialog.getContentPane().add(ssp);
    orgSearchDialog.pack();
    orgSearchDialog.setVisible(true);
  }
示例#29
0
 public void actionPerformed(ActionEvent e) {
   if (e.getSource() == addbt) {
     if (bankAccountBLService != null) {
       JDialog dialog = new JDialog(parent, "新建银行账户", true);
       dialog
           .getContentPane()
           .add(new BankAccountAddPanel(parent, dialog, this, bankAccountBLService));
       dialog.setLocationRelativeTo(parent);
       dialog.setLocation(dialog.getX() / 2, dialog.getY() / 2);
       dialog.pack();
       dialog.setVisible(true);
     } else {
       initBL();
     }
   } else if (e.getSource() == deletebt) {
     int row = table.getSelectedRow();
     if (row >= 0) {
       if (bankAccountBLService != null) {
         String account = (String) table.getValueAt(row, 0);
         try {
           bankAccountBLService.deleteBankAccount(account);
           refresh();
           new TranslucentFrame(this, MessageType.DELETE_SUCCESS, Color.GREEN);
         } catch (RemoteException e1) {
           new TranslucentFrame(this, MessageType.RMI_LAG, Color.ORANGE);
         } catch (SQLException e1) {
           System.out.println(e1.getMessage());
         }
       } else {
         initBL();
       }
     }
   } else if (e.getSource() == refreshbt) {
     refresh();
     new TranslucentFrame(this, "刷新成功", Color.GREEN);
   }
 }
示例#30
0
  protected void populateDialog(JDialog dlg) {
    dlg.setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE);
    dlg.setResizable(false);
    dlg.setSize(new Dimension(350, 135));
    dlg.setTitle("New TurboVNC Connection");

    dlg.addWindowListener(
        new WindowAdapter() {
          public void windowClosing(WindowEvent e) {
            if (VncViewer.nViewers == 1) {
              if (cc.viewer instanceof VncViewer) {
                ((VncViewer) cc.viewer).exit(1);
              }
            } else {
              ret = false;
              endDialog();
            }
          }
        });

    dlg.getContentPane().setLayout(new GridBagLayout());
    GridBagConstraints gbc = new GridBagConstraints();
    gbc.anchor = GridBagConstraints.LINE_START;
    gbc.fill = GridBagConstraints.BOTH;
    gbc.gridwidth = GridBagConstraints.REMAINDER;
    gbc.gridheight = 1;
    gbc.insets = new Insets(0, 0, 0, 0);
    gbc.ipadx = 0;
    gbc.ipady = 0;
    gbc.weightx = 1;
    gbc.weighty = 1;

    dlg.getContentPane().add(topPanel, gbc);
    dlg.getContentPane().add(buttonPanel);
    dlg.pack();
  }