@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."); } }
public int getTitleHeight(Component c) { int th = 21; int fh = getBorderInsets(c).top + getBorderInsets(c).bottom; if (c instanceof JDialog) { JDialog dialog = (JDialog) c; th = dialog.getSize().height - dialog.getContentPane().getSize().height - fh - 1; if (dialog.getJMenuBar() != null) { th -= dialog.getJMenuBar().getSize().height; } } else if (c instanceof JInternalFrame) { JInternalFrame frame = (JInternalFrame) c; th = frame.getSize().height - frame.getRootPane().getSize().height - fh - 1; if (frame.getJMenuBar() != null) { th -= frame.getJMenuBar().getSize().height; } } else if (c instanceof JRootPane) { JRootPane jp = (JRootPane) c; if (jp.getParent() instanceof JFrame) { JFrame frame = (JFrame) c.getParent(); th = frame.getSize().height - frame.getContentPane().getSize().height - fh - 1; if (frame.getJMenuBar() != null) { th -= frame.getJMenuBar().getSize().height; } } else if (jp.getParent() instanceof JDialog) { JDialog dialog = (JDialog) c.getParent(); th = dialog.getSize().height - dialog.getContentPane().getSize().height - fh - 1; if (dialog.getJMenuBar() != null) { th -= dialog.getJMenuBar().getSize().height; } } } return th; }
/** Show details. */ private void showDetails() { if (details == null) { SwingUtilities.invokeLater( new Runnable() { @Override public void run() { details = new JDialog( (JFrame) SwingUtilities.getRoot(QuaternaryVennExample.this), "Details"); QuaternaryVennList<String> list = new QuaternaryVennList<String>( vennNode.getFirstLabelText(), vennNode.getSecondLabelText(), vennNode.getThirdLabelText(), vennNode.getFourthLabelText(), vennNode.getModel()); list.setBorder(new EmptyBorder(20, 20, 20, 20)); details.setContentPane(list); details.setBounds(200, 200, 800, 800); details.setVisible(true); } }); } else { details.setVisible(true); details.requestFocusInWindow(); } }
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()); }
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(); } }); }
public static void hideOnEscape(Object ob) { if (ob instanceof JComponent) { final JComponent comp = (JComponent) ob; InputMap inputMap = comp.getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW); ActionMap actionMap = comp.getRootPane().getActionMap(); inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), actionMap); actionMap.put( actionMap, new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { comp.setVisible(false); } }); } else if (ob instanceof JDialog) { final JDialog dialog = (JDialog) ob; InputMap inputMap = dialog.getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW); ActionMap actionMap = dialog.getRootPane().getActionMap(); inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), actionMap); actionMap.put( actionMap, new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { dialog.dispose(); } }); } }
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 // // } }
private void cancelButtonActionPerformed( java.awt.event.ActionEvent evt) { // GEN-FIRST:event_cancelButtonActionPerformed // TODO add your handling code here: cancel = true; dialog.setVisible(false); dialog.dispose(); } // GEN-LAST:event_cancelButtonActionPerformed
/** * Displays a dialog with a scrollable, double-click enabled JTable. Returns the Row/Column * clicked or null if Canceled/Exited * * @param table The prepared JTable to be encapsulated in a JScollPane and a mouse event listener * added * @param message the message to be displayed * @return Row and Column (index 0 and 1 respectively) or null if no input */ public static int[] jTableDialog(JTable table, String message) { JScrollPane scroller = new JScrollPane(table); // add scroll pane to table Object[] mssg = {message, scroller}; Object[] options = {"OK", "Cancel"}; JOptionPane pane = new JOptionPane( mssg, JOptionPane.PLAIN_MESSAGE, JOptionPane.OK_CANCEL_OPTION, null, options, scroller); final JDialog dialog = pane.createDialog("Please make a selection"); table.addMouseListener( new MouseAdapter() { @Override public void mousePressed(MouseEvent e) { if (e.getClickCount() == 2) { dialog.dispose(); } } }); dialog.setResizable(true); dialog.setVisible(true); if (table.getSelectedRow() == -1 || table.getSelectedColumn() == -1 || options[1].equals(pane.getValue())) return null; int[] ret = {table.getSelectedRow(), table.getSelectedColumn()}; return ret; }
public static char[] showPasswordDialog(Component parent, String titre) { final JPasswordField jpf = new JPasswordField(); JOptionPane jop = new JOptionPane(jpf, JOptionPane.QUESTION_MESSAGE, JOptionPane.OK_CANCEL_OPTION); // FIXME: label JDialog dialog = jop.createDialog(parent, titre); dialog.addComponentListener( new ComponentAdapter() { public void componentShown(ComponentEvent e) { jpf.requestFocusInWindow(); } }); dialog.setVisible(true); if (jop.getValue() == null) { return null; } int result = (Integer) jop.getValue(); dialog.dispose(); char[] password = null; if (result == JOptionPane.OK_OPTION) { password = jpf.getPassword(); } else { return null; } return password; }
private int getConfirmChoice(String match) { Object[] btns = getConfirmButtons(); confirmDlg = new JOptionPane( "Replace with " + match + " ?", JOptionPane.QUESTION_MESSAGE, JOptionPane.DEFAULT_OPTION, null, btns, btns[0]); JDialog dlg = confirmDlg.createDialog(null, "Confirm Replace"); dlg.setVisible(true); Object res = confirmDlg.getValue(); confirmDlg = null; if (res == null) { return JOptionPane.CLOSED_OPTION; } for (int i = 0; i < btns.length; i++) { if (btns[i].equals(res)) { return i; } } return JOptionPane.CLOSED_OPTION; }
public void testContextIsJDialogWhenJDialogIsShown() { JDialog dialog = new JDialog(); JButton comp = new JButton(); dialog.getContentPane().add(comp); windowContext.setActiveWindow(comp); assertSame(dialog, windowContext.activeWindow()); }
/** Creates a new QuestionImportUI */ public QuestionImportUI() { _dialog = new JDialog(); _dialog.setIconImage(Loader.getImageIcon(Loader.IMAGE_STURESY).getImage()); _dialog.setLayout(new BorderLayout()); _loadButton = new JButton(Localize.getString("button.load")); _cancelButton = new JButton(Localize.getString("button.cancel")); _list = new JList(new DefaultListModel()); _list.setCellRenderer(new QuestionListCellRenderer(35)); JScrollPane pane = new JScrollPane(_list); JLabel label = new JLabel(Localize.getString("label.select.questions")); _dialog.add(label, BorderLayout.NORTH); _dialog.add(pane, BorderLayout.CENTER); JPanel southpanel = new JPanel(new FlowLayout(FlowLayout.CENTER)); southpanel.add(_loadButton); southpanel.add(_cancelButton); _dialog.add(southpanel, BorderLayout.SOUTH); _dialog.setSize(300, 350); }
/** * @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); }
@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(); } } }
/** * This constructor creates a new message window with the information of an email on which the * user wants to respond * * @param message : stores information of an email on which we want to respond * @throws MessagingException : Throws exception to the the function where an object of type * SendMessage has been instantiate * @throws IOException : Throws exception to the the function where an object of type SendMessage * has been instantiate */ public SendMessage(Message message) throws MessagingException, IOException { this.message = message; textArea = new JTextArea(); scrollPane = new JScrollPane(textArea); wrongMailsStringBuilder = new StringBuilder(); window = new JDialog(); username = "******"; userPassword = "******"; width = 800; height = 500; messageHandler = new MessageHandler(message); window.setSize(width, height); window.setName("send a new E-Mail"); window.setVisible(true); setTextArea(); createToLabel(); createCcLabel(); createBccLabel(); createSubjectLabel(); createCcField(); createBccField(); createSendButton(); createCancelButton(); createSaveButton(); createFormular(messageHandler, message); createContainer(); setWindowConfiguration(); }
@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 boolean openPortSettingsDialog( SerialPortConnection port, String title, String message) { port.closeConnection(); JOptionPane optionPane = new JOptionPane(); PanelSerialConfig configPanel = new PanelSerialConfig(port); Object msg[] = {message, configPanel}; optionPane.setMessage(msg); optionPane.setMessageType(JOptionPane.QUESTION_MESSAGE); optionPane.setOptionType(JOptionPane.OK_CANCEL_OPTION); JDialog dialog = optionPane.createDialog(null, title); dialog.setVisible(true); Object value = optionPane.getValue(); if (value == null || !(value instanceof Integer)) { System.out.println("Closed"); } else { int i = ((Integer) value).intValue(); if (i == JOptionPane.OK_OPTION) { try { port.getParameters().save(); // setCommPort(getPort().getParameters().getPortName()); } catch (Exception ex) { ex.printStackTrace(); } // re-open the port port.reOpenConnection(); // System.out.println("OKAY - value is: " + optionPane.getInputValue()); } else { return false; } } return 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); }
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; }
/* * 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(); }
public JDialog newImportPortfolioJDialog() { JDialog jDialog = new JDialog(mainJFrame.mainFrame, true); importPortfolioJPanel = new ImportPortfolioJPanel(jDialog); jDialog.add(importPortfolioJPanel); jDialog.pack(); return jDialog; }
@Override public void onCannotStonePlaced() { JDialog diag = new JDialog(this, CANNOT_PLACE, true); diag.setSize(new Dimension(300, 200)); JPanel pan = new JPanel(new BorderLayout()); JLabel lab = new JLabel(CANNOT_PLACE_MSG); lab.setSize(280, 190); pan.add(lab, BorderLayout.CENTER); JButton but = new JButton(VERIFY); pan.add(but, BorderLayout.SOUTH); final JDialog dia = diag; but.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { dia.dispose(); } }); diag.getContentPane().add(pan); diag.setLocationRelativeTo(null); diag.setVisible(true); }
private JDialog newAddCriteriaJDialog() { JDialog jDialog = new JDialog(mainJFrame.mainFrame, true); addNewDecEvaCriteriaJPanel = new AddNewDecEvaCriteriaJPanel(jDialog); jDialog.add(addNewDecEvaCriteriaJPanel); jDialog.pack(); return jDialog; }
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); }
/** * 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(); }
@Override public void actionPerformed(ActionEvent actionEvent) { Dimension all = parent.getSize(); Dimension d = dialog.getSize(); dialog.setLocation((all.width - d.width) / 2, (all.height - d.height) / 2); dialog.setVisible(true); }
@Override public void actionPerformed(ActionEvent e) { if (e.getSource() == btn6) { la.setText("로그인 정보가 없습니다."); JOptionPane.showMessageDialog(this, "로그아웃되셨습니다."); new LoginGUI(this); } else if (e.getSource() == btn4) { System.out.println("버튼4"); TimeSeriesDemo demo = new TimeSeriesDemo("aa"); // ChartPanel cp = demo.TimeSerie(); // jp.getLeftComponent() // p4.add(cp); JDialog tsd_jd = new JDialog(this); // .add(demo.chartPanel); } else if (e.getSource() == btn5) { // p5.add(new BMIdemo()); } else if (e.getSource() == btn8) { JDialog jd = new JDialog(this); pie1 = pcd.createDemoPanel(); jd.add(pie1); jd.setVisible(true); jd.setSize(400, 400); jd.setDefaultCloseOperation(DISPOSE_ON_CLOSE); } }
/** * Sets the dialog for this service to the specified dialog. * * @param dialog The dialog for this service to maintain. */ protected void setDialog(JDialog dialog) { this.dialog = dialog; dialog.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE); dialog.addWindowListener( new WindowAdapter() { @Override public void windowClosing(WindowEvent e) { dispose(); } }); JRootPane root = dialog.getRootPane(); root.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW) .put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), "closeDialog"); root.getActionMap() .put( "closeDialog", new AbstractAction() { private static final long serialVersionUID = 2759447330549410101L; @Override public void actionPerformed(ActionEvent e) { BaseService.this.dispose(); } }); root.setDefaultButton(defaultButton); }
@Override public void execute(ArrayList<ClassNode> classNodeList) { JOptionPane pane = new JOptionPane( "WARNING: This will load the classes into the JVM and execute allatori decrypter function" + BytecodeViewer.nl + "for each class. IF THE FILE YOU'RE LOADING IS MALICIOUS, DO NOT CONTINUE."); Object[] options = new String[] {"Continue", "Cancel"}; pane.setOptions(options); JDialog dialog = pane.createDialog(BytecodeViewer.viewer, "Bytecode Viewer - WARNING"); dialog.setVisible(true); Object obj = pane.getValue(); int result = -1; for (int k = 0; k < options.length; k++) if (options[k].equals(obj)) result = k; if (result == 0) { try { if (!className.equals("*")) { for (ClassNode classNode : classNodeList) { if (classNode.name.equals(className)) scanClassNode(classNode); } } else { for (ClassNode classNode : classNodeList) { scanClassNode(classNode); } } } catch (Exception e) { new ExceptionUI(e, "github.com/Szperak"); } finally { frame.appendText(out.toString()); frame.setVisible(true); } } }