Пример #1
1
  @Override
  public void actionPerformed(ActionEvent e) {

    OWLReasoner reasoner = owlManager.getOWLReasonerManager().getCurrentReasoner();

    if (reasoner instanceof QuestOWL) {
      try {
        check = ((QuestOWL) reasoner).getEmptyEntitiesChecker();

        JDialog dialog = new JDialog();
        dialog.setModal(true);
        dialog.setSize(520, 400);
        dialog.setLocationRelativeTo(null);
        dialog.setTitle("Empties Check");

        EmptiesCheckPanel emptiesPanel = new EmptiesCheckPanel(check);
        JPanel pnlCommandButton = createButtonPanel(dialog);
        dialog.setLayout(new BorderLayout());
        dialog.add(emptiesPanel, BorderLayout.CENTER);
        dialog.add(pnlCommandButton, BorderLayout.SOUTH);
        DialogUtils.installEscapeCloseOperation(dialog);

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

      } catch (Exception ex) {
        JOptionPane.showMessageDialog(null, "An error occured. For more info, see the logs.");
      }
    } else {
      JOptionPane.showMessageDialog(null, "You have to start ontop reasoner for this feature.");
    }
  }
Пример #2
0
 private void setHighlight(int m, int d) {
   for (int i = 0; i < 12 && month[i] != null; i++)
     if (month[i].getMonth() == m) {
       DayLabel sel = month[i].getDay(d);
       if (range && previous != null) {
         if (previous == last && !sel.before(first)) setSelection(first, sel);
         else if (previous == first && !sel.after(last)) setSelection(sel, last);
         else if (previous.before(sel)) setSelection(previous, sel);
         else setSelection(sel, previous);
       }
       setHighlight(sel);
       return;
     }
   if (m < 0) {
     setYear(month[0].getYear() - 1);
     setPreferredPanelSize();
     main.pack();
     setHighlight(11, d);
   } else if (m > 11) {
     setYear(month[0].getYear() + 1);
     setPreferredPanelSize();
     main.pack();
     setHighlight(0, d);
   }
 }
Пример #3
0
  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);
    }
  }
  /**
   * @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);
  }
 /** 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();
 }
  /** 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();
  }
Пример #7
0
  private void createPatternDialog() {

    int w = top.getSize().width;
    // int h = top.getSize().height;

    patternDialog = new JDialog(top, true);
    patternDialog.setTitle(rb.getString("dialog.pattern.title"));

    JPanel base = new JPanel(new GridLayout(2, 1));
    patternDialog.getContentPane().add(base);

    JPanel p = new JPanel(new BorderLayout());
    p.setPreferredSize(new Dimension(w * 4 / 10, 0));
    patternField = new JHistoryComboBox();
    p.add(BorderLayout.SOUTH, patternField);
    base.add(p);

    p = new JPanel();

    okPatternDialogButton = new JButton();
    okPatternDialogButton.setText(rb.getString("dialog.common.button.ok.text"));
    patternDialog.getRootPane().setDefaultButton(okPatternDialogButton);
    p.add(okPatternDialogButton);

    cancelPatternDialogButton = new JButton();
    cancelPatternDialogButton.setText(rb.getString("dialog.common.button.cancel.text"));
    p.add(cancelPatternDialogButton);
    base.add(p);

    patternDialog.pack();
  }
Пример #8
0
  private void createEditorDialog() {

    int w = top.getSize().width;
    //      int h = top.getSize().height;

    editorDialog = new JDialog(top, true);
    editorDialog.setTitle(rb.getString("dialog.editor.title"));

    JPanel base = new JPanel(new GridLayout(2, 1));
    editorDialog.getContentPane().add(base);

    JPanel p = new JPanel(new BorderLayout());
    p.setPreferredSize(new Dimension(w * 6 / 10, 0));
    editorChooser = new JFileChooserHistoryComboBox();
    editorChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
    p.add(BorderLayout.SOUTH, editorChooser);
    base.add(p);

    p = new JPanel();

    okEditorDialogButton = new JButton();
    okEditorDialogButton.setText(rb.getString("dialog.common.button.ok.text"));
    editorDialog.getRootPane().setDefaultButton(okEditorDialogButton);
    p.add(okEditorDialogButton);

    cancelEditorDialogButton = new JButton();
    cancelEditorDialogButton.setText(rb.getString("dialog.common.button.cancel.text"));
    p.add(cancelEditorDialogButton);
    base.add(p);

    editorDialog.pack();
  }
Пример #9
0
  /** Brings up a window with a scrolling text pane that display the help information. */
  private void showHelp() {
    JDialog dialog = new JDialog(this, resources.getString("dialog.help.title"));
    final JEditorPane helpText = new JEditorPane();
    try {
      URL url = getClass().getResource("GridWorldHelp.html");

      helpText.setPage(url);
    } catch (Exception e) {
      helpText.setText(resources.getString("dialog.help.error"));
    }
    helpText.setEditable(false);
    helpText.addHyperlinkListener(
        new HyperlinkListener() {
          public void hyperlinkUpdate(HyperlinkEvent ev) {
            if (ev.getEventType() == HyperlinkEvent.EventType.ACTIVATED)
              try {
                helpText.setPage(ev.getURL());
              } catch (Exception ex) {
              }
          }
        });
    JScrollPane sp = new JScrollPane(helpText);
    sp.setPreferredSize(new Dimension(650, 500));
    dialog.getContentPane().add(sp);
    dialog.setLocation(getX() + getWidth() - 200, getY() + 50);
    dialog.pack();
    dialog.setVisible(true);
  }
Пример #10
0
  /** Creates a new instance of Main */
  public Main() {

    TextElementModel textElementModel = new TextElementModel();
    DocumentModel documentModel = new DocumentModel();

    DefaultController controller = new DefaultController();

    DisplayViewPanel displayViewPanel = new DisplayViewPanel(controller);
    PropertiesViewPanel propertiesViewPanel = new PropertiesViewPanel(controller);

    controller.addView(displayViewPanel);
    controller.addView(propertiesViewPanel);
    controller.addModel(textElementModel);
    controller.addModel(documentModel);

    textElementModel.initDefault();
    documentModel.initDefault();

    JFrame displayFrame = new JFrame("Display (View 1)");
    displayFrame.getContentPane().add(displayViewPanel, BorderLayout.CENTER);
    displayFrame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
    displayFrame.pack();

    JDialog propertiesDialog = new JDialog(displayFrame, "Properties (View 2)");
    propertiesDialog.setModal(false);
    propertiesDialog.getContentPane().add(propertiesViewPanel, BorderLayout.CENTER);
    propertiesDialog.pack();

    displayFrame.setVisible(true);
    propertiesDialog.setVisible(true);
  }
Пример #11
0
  /**
   * @param aWritableModel
   * @param store
   * @return
   * @throws MessagingException
   * @throws JAXBException
   */
  private Folder getInputFolder(final GnucashWritableFile aWritableModel, Store store)
      throws MessagingException, JAXBException {
    String folderName = aWritableModel.getUserDefinedAttribute("imap.folder");
    Folder folder = null;
    if (folderName != null) {
      folder = store.getFolder(folderName);
    }
    while (folder == null || !folder.exists()) {
      final JDialog selectFolderDialog = new JDialog((JFrame) null, "Select mail folder");
      selectFolderDialog.getContentPane().setLayout(new BorderLayout());
      final JList folderListBox = new JList(new Vector<String>(getFolders(store)));
      JButton okButton = new JButton("OK");
      okButton.addActionListener(
          new ActionListener() {

            @Override
            public void actionPerformed(final ActionEvent aE) {
              if (folderListBox.getSelectedIndices() != null) {
                if (folderListBox.getSelectedIndices().length == 1) {
                  selectFolderDialog.setVisible(false);
                }
              }
            }
          });
      selectFolderDialog.getContentPane().add(new JScrollPane(folderListBox), BorderLayout.CENTER);
      selectFolderDialog.getContentPane().add(okButton, BorderLayout.SOUTH);
      selectFolderDialog.setModal(true);
      selectFolderDialog.pack();
      selectFolderDialog.setVisible(true);
      folderName = folderListBox.getSelectedValue().toString();
      aWritableModel.setUserDefinedAttribute("imap.folder", folderName);
      folder = store.getFolder(folderName);
    }
    return folder;
  }
 protected void updateScreen(Calendar c) {
   if (navPanel == null) navPanel = new NavigatePanel(this);
   // navPanel.setLabel(c);
   navPanel.setCurrentMonth(c);
   setMonthPanel(c);
   screen.pack();
 }
Пример #13
0
  /**
   * Shows the dialog. First a dialog must be constructed using one of the constructors of this
   * class. After that this method should be called to actually show the dialog. This method returns
   * either JOptionPane.OK_OPTION if the user wants to select his choices or
   * JOptionPane.CANCEL_OPTION if he does not want to.
   *
   * @param parent The parent frame of this dialog.
   * @return int The returnvalue, can be either JOptionPane.OK_OPTION or JOptionPane.CANCEL_OPTION
   */
  public int showDialog(Component parent) {
    Frame frame =
        parent instanceof Frame
            ? (Frame) parent
            : (Frame) SwingUtilities.getAncestorOfClass(Frame.class, parent);

    // String title = getUI().getDialogTitle(this);

    dialog = new JDialog(frame, title, true);
    Container contentPane = dialog.getContentPane();
    contentPane.setLayout(new BorderLayout());
    contentPane.add(this, BorderLayout.CENTER);

    dialog.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
    dialog.addWindowListener(
        new WindowAdapter() {
          public void windowClosing(WindowEvent we) {
            cancel();
          }
        });

    dialog.pack();
    dialog.setLocationRelativeTo(parent);

    dialog.setVisible(true);
    return returnValue;
  }
Пример #14
0
  public void run(DataLayer pnmlData) {
    // Build interface
    JDialog guiDialog = new JDialog(CreateGui.getApp(), MODULE_NAME, true);

    // 1 Set layout
    Container contentPane = guiDialog.getContentPane();
    contentPane.setLayout(new BoxLayout(contentPane, BoxLayout.PAGE_AXIS));

    // 2 Add file browser
    contentPane.add(sourceFilePanel = new PetriNetChooserPanel("Source net", pnmlData));

    // 3 Add results pane
    contentPane.add(results = new ResultsHTMLPane(pnmlData.getURI()));

    // 4 Add button
    contentPane.add(new ButtonBar("Analyse", analyseButtonClick));

    // 5 Make window fit contents' preferred size
    guiDialog.pack();

    // 6 Move window to the middle of the screen
    guiDialog.setLocationRelativeTo(null);

    guiDialog.setVisible(true);

    //    warnUser(pnmlData.getURI(), guiFrame);
    //    StateSpace stateSpace = new StateSpace(pnmlData);
  }
Пример #15
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;
  }
Пример #16
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();
          }
        });
  }
  private void displayFilteredDialog() {
    try {
      log.debug("displayFilteredDialog: subAction name = " + this.m_subAction.sub_action_name());
      // toolbarAction parentAction = getParentAction();

      JDialog initDebaterecord;
      initDebaterecord = new JDialog();
      initDebaterecord.setTitle("Enter Settings for Document");
      initDebaterecord.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
      // initDebaterecord.setPreferredSize(new Dimension(420, 300));

      InitDebateRecord panel =
          new InitDebateRecord(ooDocument, initDebaterecord, m_parentAction, m_subAction);
      // panel.setDialogMode(SelectorDialogModes.TEXT_INSERTION);
      // panel.setBackground(new Color(255, 255, 153));
      // initDebaterecord.setTitle("Selection Mode");
      initDebaterecord.getContentPane().add(panel);
      initDebaterecord.pack();
      initDebaterecord.setLocationRelativeTo(null);
      initDebaterecord.setVisible(true);
      initDebaterecord.setAlwaysOnTop(true);
    } catch (Exception ex) {
      log.error("displayFilteredDialog : " + ex.getMessage());
      log.error(
          "displayFilteredDialog: stack trace :  \n"
              + org.bungeni.ooo.utils.CommonExceptionUtils.getStackTrace(ex));
    }
  }
Пример #18
0
 private static void showDialog(String[] login) {
   JTextField uf = new JTextField(20);
   uf.setText(login[0]);
   JPasswordField pf = new JPasswordField(20);
   JPanel p = new JPanel(new GridBagLayout());
   GridBagConstraints gbc = new GridBagConstraints();
   gbc.anchor = GridBagConstraints.FIRST_LINE_START;
   gbc.insets.left = 5;
   gbc.insets.bottom = 5;
   gbc.gridx = 0;
   gbc.gridy = 0;
   p.add(new JLabel("User"), gbc);
   gbc.gridx = 1;
   gbc.gridy = 0;
   p.add(uf, gbc);
   gbc.gridx = 0;
   gbc.gridy = 1;
   p.add(new JLabel("Password"), gbc);
   gbc.gridx = 1;
   gbc.gridy = 1;
   p.add(pf, gbc);
   JOptionPane op = new JOptionPane(p);
   op.setOptions(new String[] {"OK", "Cancel"});
   JDialog dlg = op.createDialog(null, "Login");
   dlg.pack();
   int i = SupportUI.show(dlg, op);
   if (i != 0) {
     System.exit(0);
   }
   login[0] = uf.getText().trim();
   login[1] = new String(pf.getPassword());
 }
Пример #19
0
  public void login() {

    if (DataUser.getUsr() == null) {
      LoginDialog form = new LoginDialog();
      ODatabaseDocumentTx db = App.getDbd();
      ODatabaseRecordThreadLocal.INSTANCE.set(db);
      form.buildComponent(db);
      db.close();
      JDialog d = new JDialog(frame);
      d.setModalityType(ModalityType.APPLICATION_MODAL);
      d.getContentPane().add(form.getPanel());
      d.pack();
      setCenterDialog(d);
      d.setVisible(true);
    } else {
      // logout
      DataUser.setUsr(null);
      DataUser.setGrp(null);
      closeAllWindow();
    }
    DataUser.setAkses();
    for (HakAksesListener hakAksesListener : cangeHakAkses) {
      hakAksesListener.changeHakAkses();
    }
    //		if (DataUser.usr != null) {
    //			// open default like welcome
    //
    //		}
  }
  /*
   * 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();
  }
Пример #21
0
  @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);
  }
  /** Show the dialog. if c is null, the dialog will not have a parent. */
  public int showDialog(Component c) {
    Window topLevel = null;
    if (c != null) {
      topLevel = SwingUtilities.getWindowAncestor(c);
    }

    if (topLevel == null) {
      dialog = new JDialog();
      dialog.setModal(true);
    } else if (topLevel instanceof Frame) {
      dialog = new JDialog((Frame) topLevel, true);
    } else if (topLevel instanceof Dialog) {
      dialog = new JDialog((Dialog) topLevel, true);
    }

    dialog.getContentPane().add(this);
    dialog.setDefaultCloseOperation(dialog.DISPOSE_ON_CLOSE);

    dialog.setTitle("Arithmetic operation");
    dialog.pack();
    Misc.centerFrame(dialog);

    dialog.setVisible(true);

    return getDialogResult();
  }
Пример #23
0
 /**
  * Create a new ForceConfigAction.
  *
  * @param frame the parent frame for which to create the dialog
  * @param fsim the force simulator to configure
  */
 public ForceConfigAction(JFrame frame, ForceSimulator fsim) {
   dialog = new JDialog(frame, false);
   dialog.setTitle("Configure Force Simulator");
   JPanel forcePanel = new JForcePanel(fsim);
   dialog.getContentPane().add(forcePanel);
   dialog.pack();
 }
Пример #24
0
    @Override
    public void keyPressed(KeyEvent e) {
        int keyCode = e.getKeyCode();

         if(keyCode == KeyEvent.VK_ENTER){
            final JDialog dialog = new JDialog();
            dialog.setTitle("Search results");
            dialog.setModal(true);
            int height = 40;
            
            dialog.setBounds(0, 0, 300, 500);

            JPanel panel = new JPanel();                     
            ArrayList list = DataLayer.search(zoekBalk.getText());
            panel.setLayout(new GridLayout(list.size(), 1));
            
            if(list.size() == 0){
                JOptionPane.showMessageDialog(null, zoekBalk.getText() + " kon niet gevonden worden/ bestaat niet!", "Niet gevonden", JOptionPane.INFORMATION_MESSAGE);
                //panel.add(new JLabel(zoekBalk.getText() + " kon niet gevonden worden/ bestaat niet!"));
            }else{
                for(int i = 0; i < list.size(); i++){
                    panel.add(new JLabel(list.get(i).toString()));
                    height = height + 20;
                }
                dialog.setPreferredSize(new Dimension(200, height));
                dialog.add(panel);
                dialog.pack();
                dialog.setLocationRelativeTo(null);
                dialog.setVisible(true);
                dialog.validate();
            }
        }
    }
 private JDialog newAddCriteriaJDialog() {
   JDialog jDialog = new JDialog(mainJFrame.mainFrame, true);
   addNewDecEvaCriteriaJPanel = new AddNewDecEvaCriteriaJPanel(jDialog);
   jDialog.add(addNewDecEvaCriteriaJPanel);
   jDialog.pack();
   return jDialog;
 }
 public JDialog newImportPortfolioJDialog() {
   JDialog jDialog = new JDialog(mainJFrame.mainFrame, true);
   importPortfolioJPanel = new ImportPortfolioJPanel(jDialog);
   jDialog.add(importPortfolioJPanel);
   jDialog.pack();
   return jDialog;
 }
Пример #27
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;
 }
Пример #28
0
 private void checkYear(Calendar c) {
   if (c.get(c.YEAR) != month[0].getYear()) {
     setYear(c.get(c.YEAR));
     setPreferredPanelSize();
     main.pack();
   }
 }
Пример #29
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);
  }
Пример #30
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();
    }
  }