/** Acción realizada al pulsar el botón desasociar de la aplicación */ private void jButtonDesasociarActionPerformed() { try { LayerOperations operaciones = new LayerOperations(); // desasocia el dominio de la columna int iDeleted = operaciones.desasociarColumna(auxColumn); if (iDeleted > 0) { JOptionPane optionPane = new JOptionPane( I18N.get("GestorCapas", "general.mensaje.fin.operacion"), JOptionPane.INFORMATION_MESSAGE); JDialog dialog = optionPane.createDialog(this, ""); dialog.show(); Identificadores.put("DomainsModificados", true); jButtonAsociar.setEnabled(true); jButtonDesasociar.setEnabled(false); } else { JOptionPane optionPane = new JOptionPane( I18N.get("GestorCapas", "general.mensaje.error.operacion"), JOptionPane.ERROR_MESSAGE); JDialog dialog = optionPane.createDialog(this, ""); dialog.show(); } ; repaint(); } catch (DataException de) { de.printStackTrace(); } }
/** * 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; }
@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); } } }
public boolean showDialog() { JOptionPane jp = new JOptionPane(this, JOptionPane.PLAIN_MESSAGE, JOptionPane.OK_CANCEL_OPTION); JDialog d = jp.createDialog("Decimate parameters"); d.setResizable(true); d.setVisible(true); return Integer.valueOf(JOptionPane.OK_OPTION).equals(jp.getValue()); }
protected void editScript(boolean selectAll) { JEditorPane textEditor = new JEditorPane(); textEditor.putClientProperty(JEditorPane.HONOR_DISPLAY_PROPERTIES, true); final JRestrictedSizeScrollPane scrollPane = new JRestrictedSizeScrollPane(textEditor); scrollPane.setMinimumSize(minimumSize); textEditor.setContentType("text/groovy"); textEditor.setText(script); if (selectAll) { textEditor.selectAll(); } String title = TextUtils.getText("plugins/ScriptEditor/window.title"); final JOptionPane optionPane = new JOptionPane(scrollPane, JOptionPane.QUESTION_MESSAGE, JOptionPane.OK_CANCEL_OPTION); final JDialog dialog = optionPane.createDialog(showEditorBtn, title); dialog.setResizable(true); if (bounds != null) dialog.setBounds(bounds); dialog.setVisible(true); bounds = dialog.getBounds(); final Integer result = ((Integer) optionPane.getValue()); if (result == null || result != JOptionPane.OK_OPTION) return; script = textEditor.getText(); setButtonText(); final ActionEvent actionEvent = new ActionEvent(this, 0, null); for (final ActionListener l : actionListeners) { l.actionPerformed(actionEvent); } }
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; }
private boolean confirmClose(String action, Collection modifiedLayers) { if (modifiedLayers.isEmpty()) { return true; } JOptionPane pane = new JOptionPane( StringUtil.split( modifiedLayers.size() + " dataset" + StringUtil.s(modifiedLayers.size()) + " " + ((modifiedLayers.size() > 1) ? "have" : "has") + " been modified (" + ((modifiedLayers.size() > 3) ? "e.g. " : "") + StringUtil.toCommaDelimitedString( new ArrayList(modifiedLayers) .subList(0, Math.min(3, modifiedLayers.size()))) + "). Continue?", 80), JOptionPane.WARNING_MESSAGE); pane.setOptions(new String[] {action, "Cancel"}); pane.createDialog(this, AppContext.getMessage("GeopistaName")).setVisible(true); return pane.getValue().equals(action); }
public void handle(Throwable e) { e.printStackTrace(); JTextArea area = new JTextArea(10, 40); StringWriter writer = new StringWriter(); e.printStackTrace(new PrintWriter(writer)); area.setText(writer.toString()); area.setCaretPosition(0); String copyOption = resources.getString("dialog.error.copy"); JOptionPane pane = new JOptionPane( new JScrollPane(area), JOptionPane.ERROR_MESSAGE, JOptionPane.YES_NO_OPTION, null, new String[] {copyOption, resources.getString("cancel")}); JOptionPane pane = new JOptionPane( new JScrollPane(area), 0, 0, null, new String[] { copyOption, WorldFrame.access$600(WorldFrame.this).getString("cancel") }); pane.createDialog(WorldFrame.this, e.toString()).setVisible(true); if (copyOption.equals(pane.getValue())) { area.setSelectionStart(0); area.setSelectionEnd(area.getText().length()); area.copy(); // copy to clipboard } }
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()); }
@SuppressWarnings("empty-statement") private String getPassWd(boolean first) { String passWd = ""; JPanel panel = new JPanel(); panel.setLayout(new BoxLayout(panel, BoxLayout.PAGE_AXIS)); if (first) panel.add(new JLabel("Enter Password\n\n")); else panel.add(new JLabel("Re-enter Password\n\n")); final JPasswordField passwordField = new JPasswordField(10); // box to take passwords from the user panel.add(passwordField); JOptionPane pane = new JOptionPane(panel, JOptionPane.QUESTION_MESSAGE, JOptionPane.OK_CANCEL_OPTION) { private static final long serialVersionUID = 1L; @Override public void selectInitialValue() { passwordField.requestFocusInWindow(); } }; pane.createDialog(null, "Enter Password").setVisible(true); passWd = passwordField.getPassword().length == 0 ? null : new String(passwordField.getPassword()); passwordField.setText(""); return passWd; }
@Override public void actionPerformed(ActionEvent arg0) { try { URL url = new URL(excelUrl); HttpURLConnection connection = (HttpURLConnection) url.openConnection(); int filesize = connection.getContentLength(); float totalDataRead = 0; java.io.BufferedInputStream in = new java.io.BufferedInputStream(connection.getInputStream()); java.io.FileOutputStream fos = new java.io.FileOutputStream(excelName); java.io.BufferedOutputStream bout = new BufferedOutputStream(fos, 14921); byte[] data = new byte[14921]; int i = 0; JOptionPane jop2 = new JOptionPane("VitalHealth Test Automation Framework"); JDialog k2 = jop2.createDialog("Please wait till file is downloaded"); k2.setModal(false); k2.setVisible(true); while ((i = in.read(data, 0, 14921)) >= 0) { totalDataRead = totalDataRead + i; bout.write(data, 0, i); float Percent = (totalDataRead * 100) / filesize; } bout.close(); in.close(); // fos.close(); k2.dispose(); } catch (Exception e) { JOptionPane.showMessageDialog(null, "Sample Configuration file downloaded"); } }
private static final void showup(JOptionPane jop) { JDialog dialog = jop.createDialog(ResourceCenter.TITLE); dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE); dialog.setIconImages(ResourceCenter.icons); dialog.setModal(true); dialog.setVisible(true); dialog.dispose(); }
public void actionPerformed(ActionEvent actionevent) { OResource selectedNode = ((OResourceNode) selectedNodes.get(0).getUserObject()).getResource(); String ns = selectedNode.getONodeID().getNameSpace(); if (gate.creole.ontology.Utils.hasSystemNameSpace(selectedNode.getONodeID().toString())) { ns = ontology.getDefaultNameSpace(); } nameSpace.setText(ns); nameSpace.setText( ontology.getDefaultNameSpace() == null ? "http://gate.ac.uk/example#" : ontology.getDefaultNameSpace()); JOptionPane pane = new JOptionPane( mainPanel, JOptionPane.QUESTION_MESSAGE, JOptionPane.OK_CANCEL_OPTION, MainFrame.getIcon("ontology-instance")) { public void selectInitialValue() { instanceName.requestFocusInWindow(); instanceName.selectAll(); } }; pane.createDialog(MainFrame.getInstance(), "New Instance").setVisible(true); Object selectedValue = pane.getValue(); if (selectedValue != null && selectedValue instanceof Integer && (Integer) selectedValue == JOptionPane.OK_OPTION) { String s = nameSpace.getText(); if (!Utils.isValidNameSpace(s)) { JOptionPane.showMessageDialog( MainFrame.getInstance(), "Invalid Name Space: " + s + "\nExample: http://gate.ac.uk/example#"); return; } if (!Utils.isValidOntologyResourceName(instanceName.getText())) { JOptionPane.showMessageDialog( MainFrame.getInstance(), "Invalid Instance: " + instanceName.getText()); return; } if (Utils.getOResourceFromMap(ontology, s + instanceName.getText()) != null) { JOptionPane.showMessageDialog( MainFrame.getInstance(), "<html>" + "Resource <b>" + s + instanceName.getText() + "</b> already exists."); return; } for (int i = 0; i < selectedNodes.size(); i++) { Object obj = ((OResourceNode) selectedNodes.get(i).getUserObject()).getResource(); if (obj instanceof OClass) { ontology.addOInstance( ontology.createOURI(nameSpace.getText() + instanceName.getText()), (OClass) obj); } } } }
/** * Used to show the message dialogs to the user. @ param parent a reference to the main <code> * Word </code> object @ param msg message to be displayed in the message dialog. @ param type * type of the message dialog @ param icon icon to be shown in the message dialog @ param options * command options to be displayed in the message dialog @ param selectIndex index of the * component to be focused. */ public static int showDialog( Component parent, String msg, int option, int type, Icon icon, Object[] options, int selectIndex) { // Contains the word bundle for the current local ResourceBundle wordBundle = Word.wordBundle; String messageTitle = wordBundle.getString("MessageTitle"); String message; if (msg.indexOf("RHBD") != -1) // to show "replacement(s) have been done." message. message = msg.substring(0, msg.indexOf("RHBD") - 1) + " " + wordBundle.getString("RHBD"); else message = wordBundle.getString(msg); JOptionPane p = new JOptionPane((Object) message, option, type, null, options, options[0]); JDialog d = p.createDialog(parent, messageTitle); d.setResizable(false); d.show(); Object selectedValue = p.getValue(); if (selectedValue.equals(new Integer(-1))) { d.dispose(); return JOptionPane.CANCEL_OPTION; } if (selectedValue == null) { d.dispose(); return JOptionPane.CLOSED_OPTION; } // If there is not an array of option buttons: if (options == null) { if (selectedValue instanceof Integer) { d.dispose(); return ((Integer) selectedValue).intValue(); } d.dispose(); return JOptionPane.CLOSED_OPTION; } // If there is an array of option buttons: for (int counter = 0, maxCounter = options.length; counter < maxCounter; counter++) { if (options[counter].equals(selectedValue)) { d.dispose(); return counter; } } d.dispose(); return 0; }
public int showDialog() { panel = new JPanel(new GridBagLayout()); double lower = Double.NEGATIVE_INFINITY; double upper = Double.POSITIVE_INFINITY; if (parameter.isZeroOne) { lower = 0.0; upper = 1.0; } else if (parameter.isNonNegative) { lower = 0.0; } panel = new JPanel(new GridBagLayout()); setupComponents(); JOptionPane optionPane = new JOptionPane( panel, JOptionPane.PLAIN_MESSAGE, JOptionPane.OK_CANCEL_OPTION, null, null, null); optionPane.setBorder(new EmptyBorder(12, 12, 12, 12)); final JDialog dialog = optionPane.createDialog(frame, "Linked Parameter Setup"); priorSettingsPanel.setDialog(dialog); priorSettingsPanel.setParameter(parameter); if (OSType.isMac()) { dialog.setMinimumSize(new Dimension(dialog.getBounds().width, 300)); } else { Toolkit tk = Toolkit.getDefaultToolkit(); Dimension d = tk.getScreenSize(); if (d.height < 700 && panel.getHeight() > 450) { dialog.setSize(new Dimension(panel.getWidth() + 100, 550)); } else { // setSize because optionsPanel is shrunk in dialog dialog.setSize(new Dimension(panel.getWidth() + 100, panel.getHeight() + 100)); } // System.out.println("panel width = " + panel.getWidth()); // System.out.println("panel height = " + panel.getHeight()); } dialog.pack(); dialog.setResizable(true); dialog.setVisible(true); int result = JOptionPane.CANCEL_OPTION; Integer value = (Integer) optionPane.getValue(); if (value != null && value != -1) { result = value; } return result; }
/** * Create Message on GUI. * * @param msg */ public void createMsg(String msg) { // System.out.println(msg); // String message = "<html><font name='sansserif' size='5'/>" + msg ; JOptionPane optionPane = new JOptionPane( msg, JOptionPane.PLAIN_MESSAGE, JOptionPane.DEFAULT_OPTION, null, null, null); JDialog dialog = optionPane.createDialog(null, "SCENARIO"); dialog.setLocation(900, 430); dialog.setVisible(true); }
@Override public void actionPerformed(ActionEvent arg0) { JPanel dialog = MapillaryFilterChooseSigns.getInstance(); JOptionPane pane = new JOptionPane(dialog, JOptionPane.PLAIN_MESSAGE, JOptionPane.OK_CANCEL_OPTION); JDialog dlg = pane.createDialog(Main.parent, tr("Choose signs")); dlg.setVisible(true); if ((int) pane.getValue() == JOptionPane.OK_OPTION) MapillaryFilterDialog.getInstance().refresh(); dlg.dispose(); }
/** * Method used by the SystemIO class to get interactive user input requested by a running MIPS * program (e.g. syscall #5 to read an integer). SystemIO knows whether simulator is being run at * command line by the user, or by the GUI. If run at command line, it gets input from System.in * rather than here. * * <p>This is an overloaded method. This version, with the String parameter, is used to get input * from a popup dialog. * * @param prompt Prompt to display to the user. * @return User input. */ public String getInputString(String prompt) { String input; JOptionPane pane = new JOptionPane(prompt, JOptionPane.QUESTION_MESSAGE, JOptionPane.DEFAULT_OPTION); pane.setWantsInput(true); JDialog dialog = pane.createDialog(Globals.getGui(), "MIPS Keyboard Input"); dialog.setVisible(true); input = (String) pane.getInputValue(); this.postRunMessage(Globals.userInputAlert + input + "\n"); return input; }
/** Acción realizada al pulsar el botón de asociar de la aplicación */ private void jButtonAsociarActionPerformed() { try { // Convierte com.geopista.protocol.administrador.dominios.Domain // en com.geopista.features.Domain int idDomain = Integer.parseInt(auxDomain.getIdDomain()); String nombreDominio = auxDomain.getName(); LayerOperations operaciones = new LayerOperations(); Domain dominio = operaciones.obtenerDominioTipo(idDomain, nombreDominio); // asocia el dominio a la columna int iRes = operaciones.actualizarDominioColumna( auxColumn, dominio, Integer.parseInt(txtLevel.getText())); // auxColumn.setDomain(dominio); if (iRes > 0) { JOptionPane optionPane = new JOptionPane( I18N.get("GestorCapas", "general.mensaje.fin.operacion"), JOptionPane.INFORMATION_MESSAGE); JDialog dialog = optionPane.createDialog(this, ""); dialog.show(); Identificadores.put("DomainsModificados", true); jButtonDesasociar.setEnabled(true); } else { JOptionPane optionPane = new JOptionPane( I18N.get("GestorCapas", "general.mensaje.error.operacion"), JOptionPane.ERROR_MESSAGE); JDialog dialog = optionPane.createDialog(this, ""); dialog.show(); } repaint(); } catch (DataException de) { de.printStackTrace(); } }
private static void displayMessage( Component parentComponent, String message, String windowTitle, int messageType) { JOptionPane p = new JOptionPane(message, messageType) { public int getMaxCharactersPerLineCount() { return 72; } }; p.setMessage(message); JDialog dialog = p.createDialog(parentComponent, windowTitle); dialog.setVisible(true); }
public void handleCancel() { JOptionPane confirmation = new JOptionPane( "Do you want to exit the wizard?", JOptionPane.QUESTION_MESSAGE, JOptionPane.YES_NO_OPTION); JDialog dialog = confirmation.createDialog(getParent(), "Confirm"); dialog.setVisible(true); Object selectedValue = confirmation.getValue(); if (((Integer) selectedValue).intValue() == 0) parent.terminate(); }
public DBConnection(String user, String pass, Component fThis) { { try { url = new StringBuilder(); url.append("jdbc:postgresql://"); url.append(resources.getString("server")); url.append(":"); url.append("5432"); url.append("/"); url.append(resources.getString("database")); System.out.println(url); Class.forName("org.postgresql.Driver"); con = DriverManager.getConnection(url.toString(), user, pass); bError = true; } catch (java.sql.SQLException se) { JOptionPane jfo = new JOptionPane(se.getMessage(), JOptionPane.INFORMATION_MESSAGE); JDialog dialog = jfo.createDialog(fThis, "Message"); dialog.setModal(true); dialog.setVisible(true); bError = false; // System.exit(1); } catch (ClassNotFoundException ce) { JOptionPane jfo = new JOptionPane(ce.getMessage(), JOptionPane.INFORMATION_MESSAGE); JDialog dialog = jfo.createDialog(fThis, "Message"); dialog.setModal(true); dialog.setVisible(true); bError = false; // System.exit(1); } finally { // try { // in.close(); // } catch (IOException ex) { // Logger.getLogger(DBConnection.class.getName()).log(Level.SEVERE, null, // ex); // } } } }
/** * Shows a JDialog with a Title of title, Message of message, for a duration of seconds. After * seconds duration has elapsed or the user clicks 'OK' or closes the window, the dialog is * disposed. * * <p>Future version of this function will display and update the time remaining before the dialog * box is closed * * @param title Title of JDialog * @param message Message displayed * @param seconds Duration before dialog is automatically closed */ public static void showTimedInfoDialog(String title, String message, final int seconds) { final Object[] options = {"OK (" + seconds + "s)"}; final JOptionPane pane = new JOptionPane( message, JOptionPane.INFORMATION_MESSAGE, JOptionPane.OK_CANCEL_OPTION, null, options, options[0]); final JDialog dialog = pane.createDialog(title); Runnable runner = new Runnable() { int secondsCopy = seconds; @Override public void run() { while (secondsCopy > 0) { try { Thread.sleep(1000); secondsCopy--; Object[] options2 = {"OK (" + secondsCopy + "s)"}; pane.setOptions(options2); dialog.revalidate(); dialog.repaint(); System.out.println("Seconds: " + secondsCopy); } catch (InterruptedException ex) { // Prevent continuous loop if constantly interrupted // Todo: Update this to recover better? secondsCopy--; } } dialog.setVisible(false); dialog.dispose(); } }; Thread rThread = new Thread(runner); rThread.start(); /* Timer timer = new Timer(1000*seconds, new ActionListener() { @Override public void actionPerformed(ActionEvent e) { dialog.setVisible(false); dialog.dispose(); } }); timer.setRepeats(false); timer.start(); */ dialog.setVisible(true); }
// EDIT: in response to comment public static void showMessageDialog(Component parent, Object message, int timeout) { // run all of this on the EDT final JOptionPane optionPane = new JOptionPane(message); String title = UIManager.getString("OptionPane.messageDialogTitle"); // int style = styleFromMessageType(JOptionPane.INFORMATION_MESSAGE); final JDialog dialog = optionPane.createDialog(parent, title); // timeout default is 5000 milliseconds Timer timer = new Timer(timeout, new AutoDismiss(dialog)); timer.setRepeats(false); timer.start(); if (dialog.isDisplayable()) dialog.setVisible(true); }
public int showDialog() { options = new OptionsPanel(6, 6); options.addComponent(autoScaleCheck); JPanel panel = new JPanel(); panel.setLayout(new FlowLayout()); panel.add(fromLabel); panel.add(fromNumberField); panel.add(toLabel); panel.add(toNumberField); options.addComponent(panel); JPanel panel1 = new JPanel(); panel1.setLayout(new FlowLayout()); panel1.add(new JLabel("Width from:")); panel1.add(fromWidthField); panel1.add(new JLabel("to:")); panel1.add(toWidthField); options.addComponent(panel1); JOptionPane optionPane = new JOptionPane( options, JOptionPane.QUESTION_MESSAGE, JOptionPane.OK_CANCEL_OPTION, null, null, null); optionPane.setBorder(new EmptyBorder(12, 12, 12, 12)); final JDialog dialog = optionPane.createDialog(frame, "Setup colour range"); dialog.pack(); autoScaleCheck.addItemListener( new ItemListener() { public void itemStateChanged(ItemEvent e) { boolean enabled = !autoScaleCheck.isSelected(); fromLabel.setEnabled(enabled); fromNumberField.setEnabled(enabled); toLabel.setEnabled(enabled); toNumberField.setEnabled(enabled); } }); dialog.setVisible(true); int result = JOptionPane.CANCEL_OPTION; Integer value = (Integer) optionPane.getValue(); if (value != null && value.intValue() != -1) { result = value.intValue(); } return result; }
/** * Show the prompt and return the selection. * * @return The return value of the dialog. */ public int showPrompt() { JOptionPane optionPane = new JOptionPane(this, JOptionPane.PLAIN_MESSAGE, JOptionPane.OK_CANCEL_OPTION); JDialog dialog = optionPane.createDialog("Properties"); dialog.pack(); dialog.setVisible(true); dialog.setModal(true); if (optionPane.getValue() == null) { return JOptionPane.CANCEL_OPTION; } else { return (Integer) optionPane.getValue(); } }
public SetRhymingWordsPane() { numOfRWTF = new JTextField(); apiList = new JComboBox<>(); try { rwPropsOutput = new FileOutputStream(Strings.pathToProps + "rwProps.properties"); } catch (FileNotFoundException e) { e.printStackTrace(); } JOptionPane setRWPane = new JOptionPane(JOptionPane.OK_CANCEL_OPTION); JDialog setRWDialog; Object[] rwContents = { "Choose Which API To Use", apiList, "Choose How Many Results To Get", numOfRWTF }; String[] apis = {"Stands4", "Datamuse", "Rhymebrain"}; for (String api : apis) { apiList.addItem(api); } setRWPane.setMessage(rwContents); setRWPane.setOptionType(JOptionPane.OK_CANCEL_OPTION); setRWDialog = setRWPane.createDialog(null, "Font Settings"); setRWDialog.setVisible(true); if (setRWPane.getValue().equals(0)) { numOfRW = numOfRWTF.getText(); String chosenAPI = apiList.getSelectedItem().toString(); String finalAPI; switch (chosenAPI) { case "Stands4": finalAPI = "0"; break; case "Datamuse": finalAPI = "1"; break; case "Rhymebrain": finalAPI = "2"; break; default: finalAPI = "1"; break; } saveRwProps(finalAPI, numOfRW); } }
public OpenConnection() { try { conn = DriverManager.getConnection( "jdbc:mysql://localhost:3306/ekdothria", "root", "dotaismind"); } catch (Exception e) { JOptionPane optionPane = new JOptionPane( "Δεν μπόρεσε να συνδεθεί με την βάση.Ελέγξτε την βάση.", JOptionPane.ERROR_MESSAGE); JDialog dialog = optionPane.createDialog("Failure"); dialog.setAlwaysOnTop(true); dialog.setVisible(true); System.exit(0); } }
private static Object showDialog( final JComponent parent, final String title, final List<IEditableProperty> properties, final Object... buttonOptions) { final PropertiesUI panel = new PropertiesUI(properties, true); final JScrollPane scroll = new JScrollPane(panel); scroll.setBorder(null); scroll.getViewport().setBorder(null); final JOptionPane pane = new JOptionPane(scroll, JOptionPane.PLAIN_MESSAGE); pane.setOptions(buttonOptions); final JDialog window = pane.createDialog(JOptionPane.getFrameForComponent(parent), title); window.setVisible(true); return pane.getValue(); }