List of usage examples for javax.swing JOptionPane OK_OPTION
int OK_OPTION
To view the source code for javax.swing JOptionPane OK_OPTION.
Click Source Link
From source file:course_generator.param.frmEditCurve.java
/** * Duplicate the selected curve//from w w w .j a v a 2 s . co m * Its new name is requested */ private void DuplicateCurve() { if (!bEditMode) { Old_Paramfile = Paramfile; //-- Configuration of the panel JPanel panel = new JPanel(new GridLayout(0, 1)); panel.add(new JLabel(bundle.getString("frmEditCurve.DuplicatePanel.name.text"))); JTextField tfName = new JTextField(""); panel.add(tfName); int result = JOptionPane.showConfirmDialog(this, panel, bundle.getString("frmEditCurve.DuplicatePanel.title"), JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE); if ((result == JOptionPane.OK_OPTION) && (!tfName.getText().isEmpty())) { if (Utils.FileExist(Utils.GetHomeDir() + "/" + CgConst.CG_DIR + "/" + tfName.getText() + ".par")) { JOptionPane.showMessageDialog(this, bundle.getString("frmEditCurve.DuplicatePanel.fileexist")); return; } param.name = tfName.getText(); Paramfile = param.name; param.Save(Utils.GetHomeDir() + "/" + CgConst.CG_DIR + "/" + param.name + ".par"); ChangeEditStatus(); RefreshCurveList(); RefreshView(); } } }
From source file:com.sshtools.sshterm.SshTermSessionPanel.java
/** * * * @throws IOException//www .j av a 2s . c om */ public boolean onOpenSession() throws IOException { Window w = (Window) SwingUtilities.getAncestorOfClass(Window.class, SshTermSessionPanel.this); if (w != null) { w.toFront(); } terminal.requestFocus(); SshToolsConnectionProfile profile = getCurrentConnectionProfile(); setTerminalProperties(profile); // We are now connected statusBar.setStatusText("Connected"); statusBar.setConnected(true); this.setContainerTitle(null); //If the eol setting is EOL_DEFAULT, then use the // value guessed by j2ssh if (eol == TerminalEmulation.EOL_DEFAULT) { if (manager.getRemoteEOL() == TransportProtocolCommon.EOL_CRLF) { emulation.setEOL(TerminalEmulation.EOL_CR_LF); } else { emulation.setEOL(TerminalEmulation.EOL_CR); } } if (profile.getOnceAuthenticatedCommand() != SshToolsConnectionProfile.DO_NOTHING) { if (profile.getOnceAuthenticatedCommand() == SshToolsConnectionProfile.EXECUTE_COMMANDS) { BufferedReader reader = new BufferedReader(new StringReader(profile.getCommandsToExecute() + "\n")); String cmd; while ((cmd = reader.readLine()) != null) { if (cmd.trim().length() > 0) { log.info("Executing " + cmd); session = createNewSession(false); if (session.executeCommand(cmd)) { session.bindInputStream(emulation.getTerminalInputStream()); session.bindOutputStream(emulation.getTerminalOutputStream()); try { session.getState().waitForState(ChannelState.CHANNEL_CLOSED); } catch (InterruptedException ex) { JOptionPane.showMessageDialog(this, "The command was interrupted!", "Interrupted Exception", JOptionPane.OK_OPTION); } } } } } else { // Start the users shell session = createNewSession(true); if (session.startShell()) { session.bindInputStream(emulation.getTerminalInputStream()); session.bindOutputStream(emulation.getTerminalOutputStream()); } } } // Set the connection status setAvailableActions(); return true; }
From source file:com.net2plan.gui.utils.viewEditTopolTables.specificTables.AdvancedJTable_multicastDemand.java
private static void createMulticastDemandGUI(final NetworkElementType networkElementType, final IVisualizationCallback callback) { final NetPlan netPlan = callback.getDesign(); JTextField textFieldIngressNodeId = new JTextField(20); JTextField textFieldEgressNodeIds = new JTextField(20); JPanel pane = new JPanel(); pane.add(new JLabel("Ingress node id: ")); pane.add(textFieldIngressNodeId);/*from ww w. j ava2s . c o m*/ pane.add(Box.createHorizontalStrut(15)); pane.add(new JLabel("Egress node ids (space separated): ")); pane.add(textFieldEgressNodeIds); while (true) { int result = JOptionPane.showConfirmDialog(null, pane, "Please enter multicast demand ingress node and set of egress nodes", JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE); if (result != JOptionPane.OK_OPTION) return; try { if (textFieldIngressNodeId.getText().isEmpty()) throw new Exception("Please, insert the ingress node id"); if (textFieldEgressNodeIds.getText().isEmpty()) throw new Exception("Please, insert the set of egress node ids"); String ingressNodeId_st = textFieldIngressNodeId.getText(); String egressNodeId_st = textFieldEgressNodeIds.getText(); final long ingressNode = Long.parseLong(ingressNodeId_st); if (netPlan.getNodeFromId(ingressNode) == null) throw new Exception("Not a valid ingress node id: " + ingressNodeId_st); Set<Node> egressNodes = new HashSet<Node>(); for (String egressNodeIdString : StringUtils.split(egressNodeId_st)) { final long nodeId = Long.parseLong(egressNodeIdString); final Node node = netPlan.getNodeFromId(nodeId); if (node == null) throw new Exception("Not a valid egress node id: " + egressNodeIdString); egressNodes.add(node); } netPlan.addMulticastDemand(netPlan.getNodeFromId(ingressNode), egressNodes, 0, null); callback.getVisualizationState().resetPickedState(); callback.updateVisualizationAfterChanges( Collections.singleton(NetworkElementType.MULTICAST_DEMAND)); callback.getUndoRedoNavigationManager().addNetPlanChange(); break; } catch (Throwable ex) { ErrorHandling.addErrorOrException(ex, AdvancedJTable_multicastDemand.class); ErrorHandling.showErrorDialog("Error adding the multicast demand"); } } }
From source file:cl.almejo.vsim.gui.SimWindow.java
public int saveAs() { SAVE_AS_FILE_CHOOSER.setSelectedFile(new File(_circuit.getName())); if (SAVE_AS_FILE_CHOOSER.showSaveDialog(this) != JFileChooser.APPROVE_OPTION) { LOGGER.info("save cancelled by user."); return 0; }// w w w. ja v a 2 s. co m File file = SAVE_AS_FILE_CHOOSER.getSelectedFile(); if (file.exists()) { if (askOverwrite() != JOptionPane.YES_OPTION) { return JOptionPane.CANCEL_OPTION; } } _circuit.setName(file.getPath()); updateTitle(); save(file.getPath()); LOGGER.info("saved: " + file.getPath()); return JOptionPane.OK_OPTION; }
From source file:Classes.MainForm.java
public void locationFromInternetLabelMouseClicked(MouseEvent e) { try {/*from www. j a va 2s. co m*/ if (getLocationFromIP()) { this.locationFromInternet.setEnabled(true); this.locationFromInternet.setIcon(locationfromInternetIconMain); int result = JOptionPane.showConfirmDialog(null, PropertiesHandler.getSingleton().getValue(1049) + " : " + country + "\n" + PropertiesHandler.getSingleton().getValue(1050) + " : " + city + "\n" + PropertiesHandler.getSingleton().getValue(1051) + " : " + longitude + "\n" + PropertiesHandler.getSingleton().getValue(1052) + " : " + latitude + "\n" + PropertiesHandler.getSingleton().getValue(1053) + " : " + timezone, PropertiesHandler.getSingleton().getValue(1049) + "-" + PropertiesHandler.getSingleton().getValue(1050) + "-" + PropertiesHandler.getSingleton().getValue(1051) + "-" + PropertiesHandler.getSingleton().getValue(1052), JOptionPane.OK_CANCEL_OPTION); if (result == JOptionPane.OK_OPTION) { UserConfig.getSingleton().setCountry(country); UserConfig.getSingleton().setCity(city); UserConfig.getSingleton().setLongitude(longitude); UserConfig.getSingleton().setLatitude(latitude); UserConfig.getSingleton().setTimezone(timezone); XmlHandler.getSingleton().addUserConfig(UserConfig.getSingleton()); if (AthanPlayer.STARTED) {//kill AthanPlayer if started AthanPlayer.kill(); } java.awt.EventQueue.invokeLater(new Runnable() { @Override public void run() { try { location.setText(UserConfig.getSingleton().getCountry() + " - " + UserConfig.getSingleton().getCity()); getPrayerTimesHandler().Refresh(); switch (getPrayerTimesHandler().getActualPrayerTime()) {//set background case 0: backgroundImage = new ImageIcon(getClass().getResource(duhrBackground)) .getImage(); break; case 1: backgroundImage = new ImageIcon(getClass().getResource(shorou9Background)) .getImage(); break; case 2: backgroundImage = new ImageIcon(getClass().getResource(fajrBackground)) .getImage(); break; case 3: backgroundImage = new ImageIcon(getClass().getResource(ishaaBackground)) .getImage(); break; case 4: backgroundImage = new ImageIcon(getClass().getResource(maghribBackground)) .getImage(); break; case 5: backgroundImage = new ImageIcon(getClass().getResource(asrBackground)) .getImage(); break; default: backgroundImage = new ImageIcon(getClass().getResource(shorou9Background)) .getImage(); break; } getMainPanel().setImagePanel(getBackgroundImage()); getMainPanel().setActualPrayerTime(getPrayerTimesHandler().getActualPrayerTime()); getMainPanel().repaint(); } catch (Exception e) { try { JOptionPane.showMessageDialog(null, PropertiesHandler.getSingleton().getValue(1070), PropertiesHandler.getSingleton().getValue(1069), JOptionPane.ERROR_MESSAGE); } catch (Exception e1) { } } } }); } else { this.locationFromInternet.setEnabled(true); this.locationFromInternet.setIcon(locationfromInternetIconMain); } } else { this.locationFromInternet.setIcon(locationfromInternetIconMain); this.locationFromInternet.setEnabled(true); JOptionPane.showMessageDialog(null, PropertiesHandler.getSingleton().getValue(1104), PropertiesHandler.getSingleton().getValue(1069), JOptionPane.ERROR_MESSAGE); } } catch (Exception ex) { this.locationFromInternet.setEnabled(true); this.locationFromInternet.setIcon(locationfromInternetIconMain); } }
From source file:be.ac.ua.comp.scarletnebula.gui.windows.GUI.java
public void unlinkSelectedServers() { final Collection<Server> selectedServers = serverList.getSelectedServers(); final String unlinkString = "Unlink " + selectedServers.size() + " servers"; final int result = JOptionPane.showOptionDialog(this, "You are about to unlink " + selectedServers.size() + " server(s).\n" + "Unlinked servers are not terminated and will keep running.", unlinkString, JOptionPane.OK_CANCEL_OPTION, JOptionPane.WARNING_MESSAGE, null, Arrays.asList(unlinkString, "Cancel").toArray(), "Cancel"); if (result != JOptionPane.OK_OPTION) { return;//from www .ja v a 2 s. c o m } for (final Server server : selectedServers) { server.unlink(); } }
From source file:com.sshtools.sshterm.SshTermSessionPanel.java
private SessionChannelClient createNewSession(boolean addEventListener) throws IOException { SessionChannelClient session = manager.openSession(); session.addEventListener(dataListener); // Add the callers event listener? if (eventListener != null) { session.addEventListener(eventListener); }/* w w w .ja v a 2s . c om*/ if (addEventListener) { session.addEventListener(new ChannelEventAdapter() { public void onChannelClose(Channel channel) { closeSession(); } }); } if (getCurrentConnectionProfile().getAllowAgentForwarding()) { if (!session.requestAgentForwarding()) { JOptionPane.showMessageDialog(SshTermSessionPanel.this, "The server failed to open an agent listener", "Allow Agent Forwarding", JOptionPane.OK_OPTION, (Icon) UIManager.get("OptionPane.informationIcon")); } } // Request a pseudo terminal if (getCurrentConnectionProfile().requiresPseudoTerminal()) { if (!session.requestPseudoTerminal(emulation)) { JOptionPane.showMessageDialog(SshTermSessionPanel.this, "The server refused to allocate a pseudo terminal!", "Request Pseudo Terminal", JOptionPane.OK_OPTION); } } return session; }
From source file:com.opendoorlogistics.studio.AppFrame.java
private boolean canCloseDatastore() { if (loaded == null) { return true; }//from www. ja v a2 s. c o m if (loaded.isModified()) { if (JOptionPane.showConfirmDialog(this, "Spreadsheet has been modified but not saved. Continue without saving?", "Changes will be lost!", JOptionPane.OK_CANCEL_OPTION) != JOptionPane.OK_OPTION) { return false; } } return true; }
From source file:course_generator.param.frmEditCurve.java
/** * Add a new curve to the curve list//from ww w. ja v a 2s. c om */ protected void AddCurve() { if (!bEditMode) { JPanel panel = new JPanel(new GridLayout(0, 1)); panel.add(new JLabel(bundle.getString("frmEditCurve.AddCurvePanel.name.text"))); JTextField tfName = new JTextField(""); panel.add(tfName); int result = JOptionPane.showConfirmDialog(this, panel, bundle.getString("frmEditCurve.AddCurvePanel.title"), JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE); if ((result == JOptionPane.OK_OPTION) && (!tfName.getText().isEmpty())) { if (Utils.FileExist(Utils.GetHomeDir() + "/" + CgConst.CG_DIR + "/" + tfName.getText() + ".par")) { JOptionPane.showMessageDialog(this, bundle.getString("frmEditCurve.AddCurvePanelPanel.fileexist")); return; } //-- Add the 2 extrem points to the list and sort the list (not really necessary...) param = new ParamData(); param.name = tfName.getText(); param.data.add(new CgParam(-50.0, 0)); param.data.add(new CgParam(50.0, 0)); Collections.sort(param.data); //-- Update tablemodel.setParam(param); Old_Paramfile = Paramfile; Paramfile = param.name; bEditMode = true; ChangeEditStatus(); RefreshView(); } } }
From source file:net.sf.nmedit.nomad.core.Nomad.java
public boolean askStopApplication() { if (!stopped) { for (Document d : getDocumentManager().getDocuments()) { if (d.isModified()) { Nomad n = Nomad.sharedInstance(); int result = JOptionPane.showConfirmDialog(n.getWindow().getRootPane(), "Are you sure you want to quit without saving " + d.getTitle() + " ?\nChanges will not be lost upon quit, as the patch will be saved in the current session.", "", JOptionPane.OK_CANCEL_OPTION); if (result != JOptionPane.OK_OPTION) return false; }/* ww w.j a v a 2s .co m*/ } stop(); return stopped; } return false; }