public void actionPerformed(ActionEvent e) {
    // TODO Auto-generated method stub
    if (e.getSource() == jbNewPlayer) {
      if (currentPlayer == null) {
        JFrame playerBuild = new JFrame();
        playerBuild.setContentPane(new NewPlayer(this, playerBuild, dataBank));
        playerBuild.pack();
        playerBuild.setVisible(true);
      } else parent.startMordor(currentPlayer);
    } else if (e.getSource() == jbLoadPlayer) {
      if (currentPlayer != null) updatePlayer(null);
      else {
        if (dataBank.getPlayers().getSize() > 0) {
          String playerName =
              (String)
                  JOptionPane.showInputDialog(
                      this,
                      "Choose player",
                      "Player",
                      JOptionPane.PLAIN_MESSAGE,
                      null,
                      dataBank.getPlayerNames(),
                      0);
          updatePlayer(dataBank.getPlayer(playerName));
        } else JOptionPane.showMessageDialog(this, "No players to load.");
      }
    } else if (e.getSource() == jbExchangeItems) {
      JDialog exchangeDialog = new JDialog(this.parent, "Item Exchange", true);
      exchangeDialog.setContentPane(new ExchangeItems(exchangeDialog, dataBank));
      exchangeDialog.pack();
      exchangeDialog.setVisible(true);
    } else if (e.getSource() == jbChangePassword) {

    } else if (e.getSource() == jbDeletePlayer) {
      dataBank.removePlayer(currentPlayer);
      updatePlayer(null);
    } else if (e.getSource() == jbPlayerList) {
      JDialog playerDialog = new JDialog(this.parent, "Player List", true);
      playerDialog.setContentPane(new PlayerList(dataBank.getPlayers()));
      playerDialog.pack();
      playerDialog.setVisible(true);
    } else if (e.getSource() == jbHallOfRecords) {
      JDialog horDialog = new JDialog(this.parent, "Hall of Records", true);
      horDialog.setContentPane(new HallOfRecords(horDialog, dataBank.getPlayers()));
      horDialog.pack();
      horDialog.setVisible(true);
    } else if (e.getSource() == jbHelpLesson) {

    } else if (e.getSource() == jbOptions) {

    } else if (e.getSource() == jbExit) {
      parent.quitMordor();
    } else if (e.getSource() == jbAbout) {
      JOptionPane.showMessageDialog(this, parent.aboutMordor);
    }
  }
 /**
  * This method initializes jDialog
  *
  * @return javax.swing.JDialog
  */
 private JDialog getJDialog() {
   if (jDialog == null) {
     jDialog = new JDialog();
     jDialog.setContentPane(getJContentPane());
     jDialog.setTitle(title);
     jDialog.setSize(this.getWidth() + 5, this.getHeight() + 35);
     jDialog.setLayout(new BorderLayout());
     jDialog.getContentPane().add(this, BorderLayout.CENTER);
     jDialog.setModal(true);
     jDialog.setAlwaysOnTop(true);
     GuiUtils.centerOnScreen(jDialog);
     jDialog.setResizable(false);
     jDialog.setAlwaysOnTop(true);
     jDialog.setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE);
     jDialog.addWindowListener(
         new WindowAdapter() {
           public void windowClosing(WindowEvent e) {
             JOptionPane.showMessageDialog(jDialog, "You must enter a password!");
           }
         });
     // getJContentPane().paintImmediately(0, 0, 300, 300);
     jDialog.setIconImage(ImageUtils.getImage("images/neptus-icon.png"));
     jDialog.toFront();
     jDialog.setFocusTraversalPolicy(new PasswordPanelFocusTraversalPolicy());
     jDialog.setVisible(true);
   }
   return jDialog;
 }
 /** 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();
 }
 public void xtestTiming() {
   final JDialog dialog = new JDialog((JFrame) null, "TestTiming");
   JDesktopPane pane = new JDesktopPane();
   dialog.setContentPane(pane);
   final Object[] f = {null};
   for (int i = 99; i >= 0; i--) {
     JInternalFrame frame = new JInternalFrame("Internal Frame - " + i, true, true, true, true);
     JButton s = new JButton("button" + i);
     s.addActionListener(
         new ActionListener() {
           public void actionPerformed(ActionEvent e) {
             final long start = System.currentTimeMillis();
             System.err.println("TestMarathonNamingStrategy.testTiming(): " + start);
             namingStrategy.setTopLevelComponent(dialog, true);
             String name = namingStrategy.getName((Component) e.getSource());
             System.err.println(
                 "TestMarathonNamingStrategy.testTiming(): name = "
                     + name
                     + "::"
                     + (System.currentTimeMillis() - start));
           }
         });
     f[0] = s;
     frame.getContentPane().add(s);
     frame.pack();
     frame.setLocation(i, i);
     frame.setVisible(true);
     pane.add(frame);
   }
   dialog.setSize(500, 500);
   dialog.setModal(true);
   dialog.setVisible(true);
   System.err.println(
       "TestMarathonNamingStrategy.testTiming(): " + ((Component) f[0]).isVisible());
 }
Example #5
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;
 }
  @Test
  public void test2dPlot() {

    double[] x = new double[100]; // 1000 random numbers from a normal (Gaussian) statistical law
    double[] y = new double[100];
    for (int i = 0; i < x.length; i++) {
      x[i] = i * 0.5;
      y[i] = Math.sin(x[i]);
    }

    Plot2DPanel plot = new Plot2DPanel();

    // add a line plot to the PlotPanel
    plot.addLinePlot("my plot", x, y);
    plot.setFixedBounds(0, 0, 10);
    plot.setFixedBounds(1, -10, 10);

    plot.getAxis(0).setLightLabels();

    JFrame frame = new JFrame("a plot panel");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    final JDialog dlg = new JDialog(frame, true);
    dlg.setContentPane(plot);
    dlg.pack();
    dlg.setVisible(true);
  }
 public static void aboutSystem(Frame owner) {
   JDialog dialog = new JDialog(owner, "System Properties"); // $NON-NLS-1$
   DiagnosticsForSystem viewer = new DiagnosticsForSystem();
   dialog.setContentPane(viewer);
   dialog.setSize(500, 300);
   dialog.setVisible(true);
 }
Example #8
0
  private void loadBookmarks(JTable table) {
    final BookmarksTableModel btm = (BookmarksTableModel) table.getModel();
    List<Bookmark> bookmarks = btm.getData();

    if (bookmarks.size() > 0) {
      String message = "Clear existing bookmarks?";
      String title = "Clear Bookmarks";
      // display the JOptionPane showConfirmDialog
      int reply = JOptionPane.showConfirmDialog(null, message, title, JOptionPane.YES_NO_OPTION);
      if (reply == JOptionPane.YES_OPTION) {
        btm.clearData();
        BookmarkController.getInstance().clearBookmarks();
      }
    }

    final File selectedFile = DialogUtils.chooseFileForOpen("Load Bookmarks", null, null);

    // set the genome
    if (selectedFile != null) {

      int result =
          JOptionPane.showOptionDialog(
              null,
              "Would you like to add padding to each bookmark range?",
              "Add a margin?",
              JOptionPane.YES_NO_OPTION,
              JOptionPane.QUESTION_MESSAGE,
              null,
              null,
              null);
      final boolean addMargin = (result == JOptionPane.YES_OPTION);

      Window w = SwingUtilities.getWindowAncestor(BookmarkSheet.this);
      JOptionPane optionPane =
          new JOptionPane(
              "<html>Loading bookmarks from file.<br>This may take a moment.</html>",
              JOptionPane.INFORMATION_MESSAGE,
              JOptionPane.CANCEL_OPTION);
      final JDialog dialog = new JDialog(w, "Loading Bookmarks", Dialog.ModalityType.MODELESS);
      dialog.setContentPane(optionPane);
      dialog.pack();
      dialog.setLocationRelativeTo(w);
      dialog.setVisible(true);
      new Thread("BookmarkSheet.loadBookmarks") {
        @Override
        public void run() {
          try {
            BookmarkController.getInstance().addBookmarksFromFile(selectedFile, addMargin);
            btm.fireTableDataChanged();
          } catch (Exception ex) {
            DialogUtils.displayError("Error", "Unable to load bookmarks: " + ex.getMessage());
          } finally {
            dialog.setVisible(false);
            dialog.dispose();
          }
        }
      }.start();
    }
  }
 /**
  * This method initializes aboutDialog
  *
  * @return javax.swing.JDialog
  */
 private JDialog getAboutDialog() {
   if (aboutDialog == null) {
     aboutDialog = new JDialog(getJFrame(), true);
     aboutDialog.setTitle("About");
     aboutDialog.setContentPane(getAboutContentPane());
   }
   return aboutDialog;
 }
Example #10
0
 public static void showViewModal(JPanel view, JDialog dialog) {
   dialog.setModal(true);
   dialog.setContentPane(view);
   dialog.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
   dialog.pack();
   dialog.setLocationRelativeTo(null);
   dialog.setVisible(true);
 }
 private void doModal(JDialog dlgParent) {
   m_dlgParent = dlgParent;
   m_dlgParent.setContentPane(this);
   m_dlgParent.pack();
   m_dlgParent.setLocationRelativeTo(null);
   m_dlgParent.setVisible(true);
   m_dlgParent.dispose();
 }
  private void initComponents() {

    final SimpleDateFormat dateFrmt = new SimpleDateFormat(DEFAULT_DATE_FORMAT);
    panel = new JPanel();
    panel.setLayout(new BorderLayout());
    JPanel north = new JPanel();
    north.setLayout(new BoxLayout(north, BoxLayout.X_AXIS));
    JLabel dateLbl = new JLabel("検査日:");
    north.add(dateLbl);
    dateFld = new JTextField(10);
    dateFld.setMaximumSize(dateFld.getPreferredSize());
    dateFld.setEditable(false);
    dateFld.setText(dateFrmt.format(new Date()));
    north.add(dateFld);
    north.add(Box.createHorizontalGlue());
    editCheck = new JCheckBox("項目編集");
    north.add(editCheck);
    panel.add(north, BorderLayout.NORTH);

    JPanel south = new JPanel();
    south.setLayout(new FlowLayout());
    deleteBtn = new JButton("削除", deleteIcon);
    deleteBtn.setEnabled(false);
    south.add(deleteBtn);
    closeBtn = new JButton("閉じる", closeIcon);
    south.add(closeBtn);
    saveBtn = new JButton("保存", saveIcon);
    south.add(saveBtn);
    panel.add(south, BorderLayout.SOUTH);

    setTable = new JTable();
    JScrollPane scroll = new JScrollPane(setTable);
    centerPanel = new JPanel();
    centerPanel.setLayout(new BoxLayout(centerPanel, BoxLayout.X_AXIS));
    centerPanel.add(scroll);
    panel.add(centerPanel, BorderLayout.CENTER);

    templateTable = new JTable();
    templateTable.setToolTipText("DnDで左の施設内検査項目テーブルに追加してください。");
    rtScroll = new JScrollPane(templateTable);
    Dimension d = new Dimension(200, 200);
    rtScroll.setPreferredSize(d);
    d = new Dimension(200, Integer.MAX_VALUE);
    rtScroll.setMaximumSize(d);

    dialog = new JDialog();
    String title = ClientContext.getFrameTitle("院内検査項目追加");
    dialog.setTitle(title);
    dialog.setModal(true);
    dialog.setContentPane(panel);
    ClientContext.setDolphinIcon(dialog);

    dialog.pack();
    dialog.setLocationRelativeTo(chart.getFrame());
  }
Example #13
0
 public static JDialog showViewModal(JPanel view) {
   JDialog dialog = new JDialog();
   // if(icon != null) dialog.setIconImage(icon);
   dialog.setModal(true);
   dialog.setContentPane(view);
   dialog.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
   dialog.pack();
   dialog.setLocationRelativeTo(null);
   dialog.setVisible(true);
   return dialog;
 }
Example #14
0
 @Override
 public void actionPerformed(CommandEvent event) {
   super.actionPerformed(event);
   final OpendapAccessPanel opendapAccessPanel =
       new OpendapAccessPanel(getAppContext(), event.getCommand().getHelpId());
   final JDialog jDialog = new JDialog(getAppContext().getApplicationWindow(), "OPeNDAP Access");
   jDialog.setContentPane(opendapAccessPanel);
   jDialog.pack();
   final Dimension size = jDialog.getSize();
   jDialog.setPreferredSize(size);
   jDialog.setVisible(true);
 }
  public void showErrorDialog(Throwable th) {
    th.printStackTrace();

    ByteArrayOutputStream bos = new ByteArrayOutputStream();
    th.printStackTrace(new PrintStream(bos));

    JPanel panel = new JPanel(new BorderLayout());
    JLabel label =
        new JLabel(
            "Unexpected error occurred: '" + th.getMessage() + "' with stack trace:",
            UIManager.getIcon("OptionPane.errorIcon"),
            SwingConstants.LEFT);
    label.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    panel.add(label, BorderLayout.NORTH);
    final JTextArea text = new JTextArea(new String(bos.toByteArray()));
    text.setEditable(false);
    text.setRows(10);
    text.setColumns(50);
    panel.add(new JScrollPane(text), BorderLayout.CENTER);

    final JDialog dialog = new JDialog(getOwner(), "SQLJet Error", true);
    dialog.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
    panel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.CENTER));
    JButton button = new JButton("Close");
    button.setMnemonic('C');
    button.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            dialog.setVisible(false);
            dialog.dispose();
          }
        });
    JButton copyButton = new JButton("Copy");
    copyButton.setMnemonic('o');
    copyButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            StringSelection trace = new StringSelection(text.getText());
            Clipboard cp = Toolkit.getDefaultToolkit().getSystemClipboard();
            cp.setContents(trace, trace);
          }
        });
    buttonPanel.add(copyButton);
    buttonPanel.add(button);
    dialog.getRootPane().setDefaultButton(button);
    panel.add(buttonPanel, BorderLayout.SOUTH);
    dialog.setContentPane(panel);
    dialog.pack();
    dialog.setLocationRelativeTo(getOwner());
    dialog.setVisible(true);
  }
Example #16
0
  public void show() {
    parent = new JDialog();
    parent.setModal(true);
    parent.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
    parent.setContentPane(this);
    parent.setLocationRelativeTo(querypane);
    parent.pack();
    jButtonAccept.requestFocus();

    DialogUtils.installEscapeCloseOperation(parent);
    DialogUtils.centerDialogWRTParent(querypane, parent);
    parent.setVisible(true);
  }
Example #17
0
 public void showNewUserDialog(JFrame parent_frame) {
   if (GUITable.this.host == null) GUITable.this.host = new GUIPlayer();
   JPanel p = GUITable.this.host.getPlayerUI();
   JDialog d = new JDialog(parent_frame, true);
   d.setTitle("Player Details");
   d.setContentPane(p);
   d.pack();
   Rectangle frame_size = parent_frame.getBounds();
   Rectangle dialog_size = d.getBounds();
   dialog_size.x = frame_size.x + ((frame_size.width - dialog_size.width) / 2);
   dialog_size.y = frame_size.y + ((frame_size.height - dialog_size.height) / 2);
   d.setBounds(dialog_size);
   d.setVisible(true);
 }
 /**
  * Shows a {@link ScatterPlotPane}.
  *
  * @param parent parent component. Can be null
  * @param xAxisName name of the X-Axis
  * @param yAxisName name of the Y-Axis
  * @param chartData data to plot
  */
 public static void showDialog(
     Component parent, String xAxisName, String yAxisName, List<ScatterPlotData> chartData) {
   ScatterPlotPane scatterPlotPane = new ScatterPlotPane(parent, xAxisName, yAxisName, chartData);
   JDialog scatterPlotDialog = new JDialog();
   scatterPlotDialog.setContentPane(scatterPlotPane);
   scatterPlotDialog.setModalityType(ModalityType.APPLICATION_MODAL);
   scatterPlotDialog.setTitle("Scatter Plot");
   scatterPlotDialog.setIconImages(Images.getApplicationImages());
   scatterPlotDialog.setPreferredSize(new Dimension(DEFAULT_WIDTH, DEFAULT_HEIGHT));
   scatterPlotDialog.setMinimumSize(new Dimension(MINIMUM_WIDTH, MINIMUM_HEIGHT));
   scatterPlotDialog.pack();
   scatterPlotDialog.setLocationRelativeTo(parent);
   scatterPlotDialog.setVisible(true);
   scatterPlotDialog.dispose();
 }
 public void display() {
   try {
     dialog = new JDialog((Frame) null, "Image Type Converter Settings", false);
     dialog.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
     dialog.setContentPane(this);
     @SuppressWarnings("unused")
     GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
     dialog.pack();
     dialog.setLocationRelativeTo(null);
     dialog.setVisible(true);
   } catch (Exception e) {
     System.out.println("9\b" + getClass().getName() + ".display:\n\t" + e);
     e.printStackTrace();
   }
 }
  private ScriptManager() {
    dialog = new JDialog();
    panel = new ScriptEditorPanel(dialog);
    dialog.setTitle("Script Editor - Wonderland Client");
    // 2. Optional: What happens when the frame closes?
    dialog.setDefaultCloseOperation(JDialog.HIDE_ON_CLOSE);

    // 3. Create component and put them in the frame.
    dialog.setContentPane(panel);

    // 4. Size the frame.
    dialog.pack();

    // Next, acquire the scripting magicry
    engineManager = new ScriptEngineManager(LoginManager.getPrimary().getClassloader());
    scriptEngine = engineManager.getEngineByName("JavaScript");
    scriptBindings = scriptEngine.createBindings();

    // Add the necessary script bindings
    scriptBindings.put("Client", ClientContextJME.getClientMain());

    stringToCellID = new HashMap<String, CellID>();

    // Load the methods into the library
    ScannedClassLoader loader = LoginManager.getPrimary().getClassloader();
    Iterator<ScriptMethodSPI> iter = loader.getInstances(ScriptMethod.class, ScriptMethodSPI.class);

    // grab all global void methods
    while (iter.hasNext()) {
      final ScriptMethodSPI method = iter.next();
      addFunctionBinding(method);
      SwingUtilities.invokeLater(
          new Runnable() {
            public void run() {
              panel.addLibraryEntry(method);
            }
          });
    }

    // grab all returnablesa
    Iterator<ReturnableScriptMethodSPI> returnables =
        loader.getInstances(ReturnableScriptMethod.class, ReturnableScriptMethodSPI.class);
    while (returnables.hasNext()) {
      ReturnableScriptMethodSPI method = returnables.next();
      addFunctionBinding(method);
      panel.addLibraryEntry(method);
    }
  }
Example #21
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;
  }
Example #22
0
  @Override
  public void actionPerformed(ActionEvent e) {
    JDialog mydialog = new JDialog();
    mydialog.setSize(new Dimension(400, 500));
    mydialog.setTitle("JCR Workbench - Help");
    mydialog.setModalityType(Dialog.ModalityType.MODELESS);
    mydialog.setVisible(true);

    String url = HelpAction.class.getResource("quickStartHelp.html").toExternalForm();
    log.trace("loading help from: " + url);
    try {
      JEditorPane editorPane = new JEditorPane(url);
      JScrollPane scrolledContent = new JScrollPane(editorPane);
      mydialog.setContentPane(scrolledContent);
    } catch (IOException e1) {
      e1.printStackTrace();
    }
  }
Example #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);
  }
Example #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();
  }
  public void performAction() {

    // TODO workaround; remove AFAIK
    Beans.setDesignTime(false);

    JDialog dialog =
        new JDialog(WindowManager.getDefault().getMainWindow(), "OpenGL Capabilities", false);

    dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
    dialog.setResizable(false);
    dialog.addWindowListener(createWindowObserver());
    capsPanel = new GLCapabilitiesPanel();
    dialog.setContentPane(capsPanel);
    dialog.pack();

    dialog.setLocationRelativeTo(null);

    dialog.setVisible(true);

    EventQueue.invokeLater(createGLCapabilitiesQuery());
  }
Example #26
0
 public ReflectToolPanel(Window frame) {
   dialog = new JDialog(frame);
   dialog.setContentPane(this);
   initComponents();
   // this.setPreferredSize(new Dimension(WIDTH,HEIGHT));
   // Insets inset=dialog.getInsets();
   // dialog.setSize(new Dimension(WIDTH+inset.left+inset.right,HEIGHT+inset.top+inset.bottom));
   dialog.setLocationByPlatform(true);
   dialog.setResizable(false);
   dialog.getRootPane().setDefaultButton(okButton);
   dialog.setDefaultCloseOperation(dialog.DISPOSE_ON_CLOSE);
   dialog.setModal(true);
   dialog.setTitle("対称移動");
   angle.addChangeListener(this);
   angleSlider.addChangeListener(this);
   angle.setValue(JEnvironment.DEFAULT_REFLECT_AXIS);
   angleSlider.setValue(-JEnvironment.DEFAULT_REFLECT_AXIS);
   dialog.pack();
   int centerX = frame.getX() + (frame.getWidth() - dialog.getWidth()) / 2;
   int centerY = frame.getY() + (frame.getHeight() - dialog.getHeight()) / 2;
   dialog.setLocation(centerX, centerY);
   okButton.requestFocus();
   dialog.setVisible(true);
 }
Example #27
0
  private boolean showDialog(Component root, String title, boolean decorated) {
    if (dialog != null) {
      throw new IllegalStateException("Dialog already exists");
    }
    dialog = Util.newJDialog(root, title, modal);
    if (!decorated) {
      dialog.setUndecorated(true);
    }

    JRootPane rootPane = dialog.getRootPane();
    JPanel buttonpanel = new JPanel(new FlowLayout(FlowLayout.RIGHT));

    // Do this to reorder buttons so "cancel" and "ok" are last!
    // For Windows L&F, cancel button is on the right. For Nimbus
    // check the "isYesLast" option.
    boolean cancelonright = Util.isLAFWindows() || !UIManager.getBoolean("OptionPane.isYesLast");

    if (actions.containsKey("cancel") && !cancelonright) {
      actions.put("cancel", actions.remove("cancel"));
    }
    if (actions.containsKey("ok")) {
      actions.put("ok", actions.remove("ok"));
    }
    if (actions.containsKey("cancel") && cancelonright) {
      actions.put("cancel", actions.remove("cancel"));
    }
    for (Iterator<Map.Entry<String, Action>> i = actions.entrySet().iterator(); i.hasNext(); ) {
      Map.Entry<String, Action> e = i.next();
      String name = e.getKey();
      Action action = e.getValue();
      rootPane.getActionMap().put(name, action);
      buttonpanel.add(new JButton(action));
      for (Iterator<Map.Entry<KeyStroke, String>> j = keystrokes.entrySet().iterator();
          j.hasNext(); ) {
        Map.Entry<KeyStroke, String> e2 = j.next();
        if (e2.getValue().equals(name)) {
          rootPane
              .getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT)
              .put(e2.getKey(), e2.getValue());
        }
      }
    }

    GridBagConstraints gbc = new GridBagConstraints();
    gbc.gridwidth = gbc.REMAINDER;
    gbc.anchor = gbc.EAST;
    gbc.weighty = 0.01;
    add(buttonpanel, gbc);

    dialog.setContentPane(this);
    dialog.setResizable(true);
    dialog.pack();
    dialog.setLocationRelativeTo(root);
    dialog.setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE);
    dialog.addWindowListener(
        new WindowAdapter() {
          public void windowClosing(WindowEvent event) {
            if (actions.containsKey("cancel")) {
              cancelDialog();
            } else {
              acceptDialog();
            }
          }
        });
    dialog.setVisible(true);
    return response;
  }
Example #28
0
  /**
   * Displays the VCard for an individual.
   *
   * @param vCard the users vcard.
   * @param parent the parent component, used for location.
   */
  public void editProfile(final VCard vCard, JComponent parent) {
    final JTabbedPane tabbedPane = new JTabbedPane();

    // Initialize Panels
    personalPanel = new PersonalPanel();
    personalPanel.showJID(false);

    businessPanel = new BusinessPanel();
    homePanel = new HomePanel();
    avatarPanel = new AvatarPanel();
    // employeePanel		= new EmployeePanel();

    String employeeOf = vCard.getField("employeeOf");
    if (vCard.getJabberId()
        == SparkManager.getUserManager()
            .getJIDFromDisplayName(SparkManager.getUserManager().getNickname())) {
      if ((employeeOf == null || employeeOf.isEmpty())) {
        employeeListPanel = new EmployeeListPanel();

        tabbedPane.addTab(Res.getString("tab.home"), homePanel);
        tabbedPane.addTab(Res.getString("tab.business"), personalPanel);
        tabbedPane.addTab(Res.getString("tab.business"), businessPanel);
        tabbedPane.addTab(Res.getString("tab.employees"), employeeListPanel); // zmienione
        employee = false;
      } else {
      }
    }

    tabbedPane.addTab(Res.getString("tab.avatar"), avatarPanel);

    // Build the UI
    buildUI(vCard);

    final JOptionPane pane;
    final JDialog dlg;

    TitlePanel titlePanel;

    ImageIcon icon = VCardManager.getAvatarIcon(vCard);
    if (icon == null) {
      icon = SparkRes.getImageIcon(SparkRes.BLANK_24x24);
    }

    // Create the title panel for this dialog
    titlePanel =
        new TitlePanel(
            Res.getString("title.edit.profile"), Res.getString("message.save.profile"), icon, true);

    // Construct main panel w/ layout.
    final JPanel mainPanel = new JPanel();
    mainPanel.setLayout(new BorderLayout());
    mainPanel.add(titlePanel, BorderLayout.NORTH);

    // The user should only be able to close this dialog.
    Object[] options = {Res.getString("save"), Res.getString("cancel")};
    pane =
        new JOptionPane(
            tabbedPane,
            JOptionPane.PLAIN_MESSAGE,
            JOptionPane.OK_CANCEL_OPTION,
            null,
            options,
            options[0]);

    mainPanel.add(pane, BorderLayout.CENTER);

    JOptionPane p = new JOptionPane();
    dlg = p.createDialog(parent, Res.getString("title.profile.information"));
    dlg.setModal(false);

    dlg.pack();
    dlg.setSize(600, 400);
    dlg.setResizable(true);
    dlg.setContentPane(mainPanel);
    dlg.setLocationRelativeTo(parent);

    PropertyChangeListener changeListener =
        new PropertyChangeListener() {
          public void propertyChange(PropertyChangeEvent e) {
            String value = (String) pane.getValue();
            if (Res.getString("cancel").equals(value)) {
              pane.removePropertyChangeListener(this);
              dlg.dispose();
            } else if (Res.getString("save").equals(value)) {
              //                    pane.removePropertyChangeListener(this);
              // dlg.dispose();
              // saveVCard();
              preSaveVCard();
            }
          }
        };

    // JPanel bottomPanel = (JPanel)pane.getComponent(0);

    JButton saveButton = new JButton();

    tabbedPane.addChangeListener(
        new ChangeListener() {

          @Override
          public void stateChanged(ChangeEvent e) {
            preSaveVCard();
          }
        });

    for (Component component : pane.getComponents()) {
      if (component instanceof JButton) {
        JButton b = (JButton) component;

        if (b.getText().equalsIgnoreCase("Save")) {
          saveButton = (JButton) component;
        }
      }
    }

    saveButton.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent e) {
            preSaveVCard();
          }
        });

    avatarPanel.setParentDialog(dlg);
    dlg.setVisible(true);
    dlg.toFront();
    dlg.requestFocus();

    personalPanel.focus();
  }
Example #29
0
  /**
   * Displays the VCard for an individual.
   *
   * @param vCard the users vcard.
   * @param parent the parent component, used for location.
   */
  public void viewFullProfile(final VCard vCard, JComponent parent) {
    final JTabbedPane tabbedPane = new JTabbedPane();

    // Initialize Panels
    personalPanel = new PersonalPanel();
    personalPanel.allowEditing(false);
    personalPanel.showJID(false);

    //        tabbedPane.addTab(Res.getString("tab.personal"), personalPanel);

    businessPanel = new BusinessPanel();
    businessPanel.allowEditing(false);
    tabbedPane.addTab(Res.getString("tab.business"), businessPanel);

    homePanel = new HomePanel();
    homePanel.allowEditing(false);
    //        tabbedPane.addTab(Res.getString("tab.home"), homePanel);

    avatarPanel = new AvatarPanel();
    avatarPanel.allowEditing(false);
    tabbedPane.addTab(Res.getString("tab.avatar"), avatarPanel);

    //        employeePanel = new EmployeePanel();
    //        employeePanel.allowEditing(false);
    //        tabbedPane.addTab("Pracownicy", employeePanel);

    String employeeOf = vCard.getField("employeeOf");
    if (vCard.getJabberId()
        == SparkManager.getUserManager()
            .getJIDFromDisplayName(SparkManager.getUserManager().getNickname())) {
      if ((employeeOf == null || employeeOf.isEmpty())) {
        employeeListPanel = new EmployeeListPanel();
        tabbedPane.addTab(Res.getString("tab.home"), homePanel);
        tabbedPane.addTab(Res.getString("tab.business"), businessPanel);
        tabbedPane.addTab("Pracownicy", employeeListPanel);
        employee = false;
      } else {

      }
    }

    // Build the UI
    buildUI(vCard);

    final JOptionPane pane;
    final JDialog dlg;

    TitlePanel titlePanel;

    ImageIcon icon = VCardManager.getAvatarIcon(vCard);
    if (icon == null) {
      icon = SparkRes.getImageIcon(SparkRes.BLANK_24x24);
    }

    // Create the title panel for this dialog
    titlePanel = new TitlePanel(Res.getString("title.profile.information"), "", icon, true);

    // Construct main panel w/ layout.
    final JPanel mainPanel = new JPanel();
    mainPanel.setLayout(new BorderLayout());
    mainPanel.add(titlePanel, BorderLayout.NORTH);

    // The user should only be able to close this dialog.
    Object[] options = {Res.getString("close")};
    pane =
        new JOptionPane(
            tabbedPane,
            JOptionPane.PLAIN_MESSAGE,
            JOptionPane.OK_CANCEL_OPTION,
            null,
            options,
            options[0]);

    mainPanel.add(pane, BorderLayout.CENTER);

    JOptionPane p = new JOptionPane();
    dlg = p.createDialog(parent, Res.getString("title.profile.information"));
    dlg.setModal(false);

    dlg.pack();
    dlg.setSize(600, 400);
    dlg.setResizable(true);
    dlg.setContentPane(mainPanel);
    dlg.setLocationRelativeTo(parent);

    PropertyChangeListener changeListener =
        new PropertyChangeListener() {
          public void propertyChange(PropertyChangeEvent e) {
            Object o = pane.getValue();
            if (o instanceof Integer) {
              pane.removePropertyChangeListener(this);
              dlg.dispose();
              return;
            }

            String value = (String) pane.getValue();
            if (Res.getString("close").equals(value)) {
              pane.removePropertyChangeListener(this);
              dlg.dispose();
            }
          }
        };

    pane.addPropertyChangeListener(changeListener);

    dlg.setVisible(true);
    dlg.toFront();
    dlg.requestFocus();

    personalPanel.focus();
  }
  @SuppressWarnings("rawtypes")
  public static void runReport(
      List<List> customerData,
      List<List> projectData,
      JCheckBox markErrorsCheckBox,
      JTextField frameAgreement,
      JTextField category,
      File output,
      JFrame frame) {

    final JDialog dialog = new JDialog();
    final ExcelDocumentCreator creator;
    JPanel contentPane;

    dialog.setTitle("Creating report");
    dialog.setBounds(100, 100, 560, 189);
    contentPane = new JPanel();
    contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
    dialog.setContentPane(contentPane);
    SpringLayout sl_contentPane = new SpringLayout();
    contentPane.setLayout(sl_contentPane);

    JPanel panel = new JPanel();
    panel.setBorder(BorderFactory.createMatteBorder(0, 0, 1, 0, Color.black));
    sl_contentPane.putConstraint(SpringLayout.NORTH, panel, -5, SpringLayout.NORTH, contentPane);
    panel.setBackground(Color.white);
    sl_contentPane.putConstraint(SpringLayout.WEST, panel, -5, SpringLayout.WEST, contentPane);
    sl_contentPane.putConstraint(SpringLayout.EAST, panel, 5, SpringLayout.EAST, contentPane);
    sl_contentPane.putConstraint(SpringLayout.SOUTH, panel, -50, SpringLayout.SOUTH, contentPane);
    contentPane.add(panel);

    JPanel panel_1 = new JPanel();
    sl_contentPane.putConstraint(SpringLayout.WEST, panel_1, -5, SpringLayout.WEST, contentPane);
    sl_contentPane.putConstraint(SpringLayout.SOUTH, panel_1, 5, SpringLayout.SOUTH, contentPane);
    sl_contentPane.putConstraint(SpringLayout.NORTH, panel_1, 90, SpringLayout.NORTH, contentPane);
    sl_contentPane.putConstraint(SpringLayout.EAST, panel_1, 5, SpringLayout.EAST, contentPane);
    SpringLayout sl_panel = new SpringLayout();
    panel.setLayout(sl_panel);

    final JProgressBar progressBar = new JProgressBar();
    sl_panel.putConstraint(SpringLayout.NORTH, progressBar, -50, SpringLayout.SOUTH, panel);
    sl_panel.putConstraint(SpringLayout.WEST, progressBar, 20, SpringLayout.WEST, panel);
    panel.add(progressBar);

    JTextField stateField = new JTextField("Querying Database");
    sl_panel.putConstraint(SpringLayout.EAST, progressBar, 247, SpringLayout.EAST, stateField);
    sl_panel.putConstraint(SpringLayout.NORTH, stateField, 10, SpringLayout.NORTH, panel);
    sl_panel.putConstraint(SpringLayout.WEST, stateField, 10, SpringLayout.WEST, panel);
    stateField.setBorder(BorderFactory.createEmptyBorder());
    panel.add(stateField);
    stateField.setColumns(10);

    JTextField progressField = new JTextField();
    sl_panel.putConstraint(SpringLayout.SOUTH, progressBar, -6, SpringLayout.NORTH, progressField);
    sl_panel.putConstraint(SpringLayout.WEST, progressField, 10, SpringLayout.WEST, panel);
    sl_panel.putConstraint(SpringLayout.EAST, progressField, -257, SpringLayout.EAST, panel);
    sl_panel.putConstraint(SpringLayout.EAST, stateField, 0, SpringLayout.EAST, progressField);
    progressField.setBorder(BorderFactory.createEmptyBorder());
    sl_panel.putConstraint(SpringLayout.SOUTH, progressField, -10, SpringLayout.SOUTH, panel);
    panel.add(progressField);
    progressField.setColumns(10);
    contentPane.add(panel_1);
    SpringLayout sl_panel_1 = new SpringLayout();
    panel_1.setLayout(sl_panel_1);

    JButton btnCancel =
        new JButton("Cancel") {
          private static final long serialVersionUID = 1L;

          public void addNotify() {
            super.addNotify();
            requestFocus();
          }
        };

    sl_panel_1.putConstraint(SpringLayout.SOUTH, btnCancel, -10, SpringLayout.SOUTH, panel_1);
    sl_panel_1.putConstraint(SpringLayout.EAST, btnCancel, -10, SpringLayout.EAST, panel_1);
    panel_1.add(btnCancel);

    progressBar.setIndeterminate(true);

    creator =
        new ExcelDocumentCreator(
            customerData,
            projectData,
            frameAgreement,
            markErrorsCheckBox,
            category,
            stateField,
            progressField,
            output);
    creator.addPropertyChangeListener(
        new PropertyChangeListener() {
          @Override
          public void propertyChange(PropertyChangeEvent evt) {
            if (creator.isDone()) dialog.dispose();

            if ("progress".equals(evt.getPropertyName())) {
              progressBar.setValue((Integer) evt.getNewValue());
              progressBar.setIndeterminate(false);
            }
          }
        });
    creator.execute();

    btnCancel.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            creator.cancel(true);
          }
        });

    dialog.addWindowListener(
        new WindowAdapter() {
          @Override
          public void windowClosing(WindowEvent evt) {
            creator.cancel(true);
            dialog.dispose();
          }
        });

    dialog.setModalityType(ModalityType.APPLICATION_MODAL);
    dialog.setLocationRelativeTo(frame);
    dialog.setResizable(false);
    dialog.setVisible(true);
  }