List of usage examples for javax.swing JOptionPane OK_CANCEL_OPTION
int OK_CANCEL_OPTION
To view the source code for javax.swing JOptionPane OK_CANCEL_OPTION.
Click Source Link
showConfirmDialog
. From source file:patientmanagerv1.HomeController.java
public void deleteProgressReport() { /*try{/*from w w w .j a v a2s . co m*/ String currRep = listOfProgressReports.getSelectionModel().getSelectedItem().toString(); String currRepNoColons = currRep.replace(":", ""); currRepNoColons = currRepNoColons.trim(); int result = JOptionPane.showConfirmDialog(null, "Are you sure you want to delete this progress note?","Warning", JOptionPane.OK_CANCEL_OPTION); //System.out.println(result); //JOptionPane.showConfirmDialog(null, "Would you like to save any changes before logging out?", "save changes?", YES_NO_CANCEL_OPTION); //Object selection = JOptionPane.get if(result == 0) { //0 is "OK" //System.out.println("pressed ok"); //locates the current report try{ String cR = listOfProgressReports.getSelectionModel().getSelectedItem().toString(); String cRNC = cR.replace(":", ""); //1) removes the report from the list in the file try { FileReader r2 = new FileReader(installationPath + "/userdata/" + firstName + lastName + dob + "/ProgressReports.txt"); BufferedReader b2 = new BufferedReader(r2); String s; ArrayList progressNotes = new ArrayList(); while((s = b2.readLine()) != null) { //System.out.println(s); if(!s.equalsIgnoreCase(currRep)) {progressNotes.add(s);} } b2.close(); r2.close(); File fff = new File(installationPath + "/userdata/" + firstName + lastName + dob + "/ProgressReports.txt"); FileWriter ddd = new FileWriter(fff, false); BufferedWriter bw = new BufferedWriter(ddd); ddd.append(""); bw.close(); ddd.close(); for(int i = 0; i < progressNotes.size(); i++) { File openProgressReportsList = new File(installationPath + "/userdata/" + firstName + lastName + dob + "/ProgressReports.txt"); FileWriter fw = new FileWriter(openProgressReportsList, true); BufferedWriter bufferedwriter = new BufferedWriter(fw); fw.append(progressNotes.get(i) + "\n"); bufferedwriter.close(); fw.close(); } } catch(Exception e) { } /*try{ FileReader reader = new FileReader(installationPath + "/userdata/" + firstName + lastName + dob + "/ProgressReports.txt"); BufferedReader br = new BufferedReader(reader); String fileContents = br.readLine(); br.close(); reader.close(); fileContents = fileContents.replace(currRep, ""); //System.out.println("fc:" + fileContents); //writes the new contents to the file: //writes the new report to the list File openProgressReportsList = new File(installationPath + "/userdata/" + firstName + lastName + dob + "/ProgressReports.txt"); FileWriter fw = new FileWriter(openProgressReportsList, false); BufferedWriter bufferedwriter = new BufferedWriter(fw); fw.append(fileContents); bufferedwriter.close(); fw.close(); } catch(Exception e) { }*/ //2) Deletes the folder for that progress report /*try { File path = new File(installationPath + "/userdata/" + firstName + lastName + dob + "/ProgressNotes/" + currRepNoColons); File[] files = path.listFiles(); for(int i = 0; i<files.length; i++) { files[i].delete(); } //the wedding nightmare: red, red, dark purple-brown; big-ol red wrap/red jacket path.delete(); //deleteDirectory(installationPath + "/userdata/" + firstName + lastName + dob + "/ProgressNotes/" + currRepNoColons); //Files.delete(installationPath + "/userdata/" + firstName + lastName + dob + "/ProgressNotes/" + currRepNoColons); } catch(Exception e) {} //3) removes the report from the listview (clears and then repopulates the list) listOfProgressReports.getItems().clear(); try { FileReader r2 = new FileReader(installationPath + "/userdata/" + firstName + lastName + dob + "/ProgressReports.txt"); BufferedReader b2 = new BufferedReader(r2); String s; ArrayList progressNotes = new ArrayList(); while((s = b2.readLine()) != null) { System.out.println(s); progressNotes.add(s); } b2.close(); r2.close(); //Adds the Progress Notes to the ListView ObservableList<String> items = FXCollections.observableArrayList ( "Single", "Double"); items.clear(); for(int counter = 0; counter < progressNotes.size(); counter++) { items.add(progressNotes.get(counter).toString()); } listOfProgressReports.setItems(items); //String[] ethnicityArray = ethnicity.split(","); } catch (Exception e) { System.out.println("file not found"); } } catch(Exception e) { JOptionPane.showMessageDialog(null, "Please select a progress report from the list and try again"); } } if(result == 2) { //2 is "Cancel" //System.out.println("pressed cancel"); } } catch(Exception e) {JOptionPane.showMessageDialog(null, "Please select a progress report from the list and try again");}*/ try { String currRep = listOfProgressReports.getSelectionModel().getSelectedItem().toString(); String currRepNoColons = currRep.replace(":", ""); currRepNoColons = currRepNoColons.trim(); int result = JOptionPane.showConfirmDialog(null, "Are you sure you want to delete this progress note?", "Warning", JOptionPane.OK_CANCEL_OPTION); //System.out.println(result); //JOptionPane.showConfirmDialog(null, "Would you like to save any changes before logging out?", "save changes?", YES_NO_CANCEL_OPTION); //Object selection = JOptionPane.get if (result == 0) { //0 is "OK" //System.out.println("pressed ok"); //locates the current report try { String cR = listOfProgressReports.getSelectionModel().getSelectedItem().toString(); String cRNC = cR.replace(":", ""); //1) removes the report from the list in the file try { FileReader r2 = new FileReader(installationPath + "/userdata/" + firstName + lastName + dob + "/ProgressReports.txt"); BufferedReader b2 = new BufferedReader(r2); String s; ArrayList progressNotes = new ArrayList(); while ((s = b2.readLine()) != null) { //System.out.println(s); if (!s.equalsIgnoreCase(currRep)) { progressNotes.add(s); } } b2.close(); r2.close(); File fff = new File(installationPath + "/userdata/" + firstName + lastName + dob + "/ProgressReports.txt"); FileWriter ddd = new FileWriter(fff, false); BufferedWriter bw = new BufferedWriter(ddd); ddd.append(""); bw.close(); ddd.close(); for (int i = 0; i < progressNotes.size(); i++) { File openProgressReportsList = new File(installationPath + "/userdata/" + firstName + lastName + dob + "/ProgressReports.txt"); FileWriter fw = new FileWriter(openProgressReportsList, true); BufferedWriter bufferedwriter = new BufferedWriter(fw); fw.append(progressNotes.get(i) + "\n"); bufferedwriter.close(); fw.close(); } } catch (Exception e) { } /*try{ FileReader reader = new FileReader(installationPath + "/userdata/" + firstName + lastName + dob + "/ProgressReports.txt"); BufferedReader br = new BufferedReader(reader); String fileContents = br.readLine(); br.close(); reader.close(); fileContents = fileContents.replace(currRep, ""); //System.out.println("fc:" + fileContents); //writes the new contents to the file: //writes the new report to the list File openProgressReportsList = new File(installationPath + "/userdata/" + firstName + lastName + dob + "/ProgressReports.txt"); FileWriter fw = new FileWriter(openProgressReportsList, false); BufferedWriter bufferedwriter = new BufferedWriter(fw); fw.append(fileContents); bufferedwriter.close(); fw.close(); } catch(Exception e) { }*/ //2) Deletes the folder for that progress report try { File path = new File(installationPath + "/userdata/" + firstName + lastName + dob + "/ProgressNotes/" + currRepNoColons); File[] files = path.listFiles(); for (int i = 0; i < files.length; i++) { files[i].delete(); } //the wedding nightmare: red, red, dark purple-brown; big-ol red wrap/red jacket path.delete(); //deleteDirectory(installationPath + "/userdata/" + firstName + lastName + dob + "/ProgressNotes/" + currRepNoColons); //Files.delete(installationPath + "/userdata/" + firstName + lastName + dob + "/ProgressNotes/" + currRepNoColons); } catch (Exception e) { } //3) removes the report from the listview (clears and then repopulates the list) listOfProgressReports.getItems().clear(); try { FileReader r2 = new FileReader(installationPath + "/userdata/" + firstName + lastName + dob + "/ProgressReports.txt"); BufferedReader b2 = new BufferedReader(r2); String s; ArrayList progressNotes = new ArrayList(); while ((s = b2.readLine()) != null) { //System.out.println(s); progressNotes.add(s); } b2.close(); r2.close(); //Adds the Progress Notes to the ListView ObservableList<String> items = FXCollections.observableArrayList("Single", "Double"); items.clear(); for (int counter = 0; counter < progressNotes.size(); counter++) { items.add(progressNotes.get(counter).toString()); } listOfProgressReports.setItems(items); //String[] ethnicityArray = ethnicity.split(","); } catch (Exception e) { //System.out.println("file not found"); } } catch (Exception e) { JOptionPane.showMessageDialog(null, "Please select a progress report from the list and try again"); } } if (result == 2) { //2 is "Cancel" //System.out.println("pressed cancel"); } } catch (Exception e) { JOptionPane.showMessageDialog(null, "Please select a progress report from the list and try again"); } listOfProgressReports.getSelectionModel().clearSelection(); }
From source file:pl.edu.pw.appt.GUI.java
private void jMenuItem4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem4ActionPerformed boolean zal = false; JTextField z1 = new JTextField(); JTextField z2 = new JTextField(); Object[] message = { "Zdarzenie 1", z1, "Zdarzenie 2", z2 }; JOptionPane pane = new JOptionPane(message, JOptionPane.PLAIN_MESSAGE, JOptionPane.OK_CANCEL_OPTION); pane.createDialog(null, "Badanie zdarze").setVisible(true); if (selectSystem.getSelectedIndex() != -1) { zal = server.messages.isDependent1(Integer.parseInt(z1.getText()), Integer.parseInt(z2.getText()), selectSystem.getSelectedItem().toString()); JOptionPane.showMessageDialog(null, zal ? "Zdarzenia s zalene" : "Zdarzenia s niezalene", "Badanie zdarze", JOptionPane.WARNING_MESSAGE); }/*ww w. ja v a 2 s. c o m*/ }
From source file:pl.otros.logview.gui.actions.ConnectToSocketHubAppenderAction.java
private boolean chooseLogImporter() { DataConfiguration configuration = getOtrosApplication().getConfiguration(); List<Object> list1 = configuration.getList(ConfKeys.SOCKET_HUB_APPENDER_ADDRESSES); configuration.getInt(ConfKeys.SOCKET_HUB_APPENDER_ADDRESSES_MAX_COUNT, 20); Vector<String> recent = new Vector<String>(); for (Object o : list1) { recent.add(o.toString());// w w w . j a v a 2s. com } JXComboBox box = new JXComboBox(recent); box.setEditable(true); AutoCompleteDecorator.decorate(box); MigLayout migLayout = new MigLayout(); JPanel panel = new JPanel(migLayout); panel.add(new JLabel("Host name:port")); panel.add(box, "wrap, width 200:220:440"); while (true) { String[] options = { "Connect", "Cancel" }; int showConfirmDialog = JOptionPane.showOptionDialog(getOtrosApplication().getApplicationJFrame(), panel, "Enter host name and port", JOptionPane.OK_CANCEL_OPTION, JOptionPane.INFORMATION_MESSAGE, null, options, options[0]); if (showConfirmDialog != JOptionPane.OK_OPTION) { return false; } try { String hostAndPortString = box.getSelectedItem().toString().trim(); socket = tryToConnectToSocket(configuration, hostAndPortString, SocketFactory.getDefault()); } catch (UnknownHostException e) { JOptionPane.showMessageDialog(panel, host + " is unknown host name", "Error", JOptionPane.ERROR_MESSAGE); continue; } catch (IOException e) { JOptionPane.showMessageDialog(panel, "Cannot connect to host " + host + ":" + port, "Error", JOptionPane.ERROR_MESSAGE); continue; } catch (NumberFormatException e) { JOptionPane.showMessageDialog(panel, "Can't parse port number.", "Error", JOptionPane.ERROR_MESSAGE); continue; } return true; } }
From source file:pl.otros.logview.gui.actions.StartSocketListener.java
private LogImporterAndPort chooseLogImporter() { Collection<LogImporter> elements = AllPluginables.getInstance().getLogImportersContainer().getElements(); LogImporter[] importers = elements.toArray(new LogImporter[0]); String[] names = new String[elements.size()]; for (int i = 0; i < names.length; i++) { names[i] = importers[i].getName(); }/* w ww .ja va 2 s . c om*/ JComboBox box = new JComboBox(names); SpinnerNumberModel numberModel = new SpinnerNumberModel(50505, 1025, 65000, 1); JSpinner jSpinner = new JSpinner(numberModel); MigLayout migLayout = new MigLayout(); JPanel panel = new JPanel(migLayout); panel.add(new JLabel("Select log importer")); panel.add(box, "wrap"); panel.add(new JLabel("Select port")); panel.add(jSpinner, "span"); if (logReaders.size() > 0) { panel.add(new JLabel("Opened sockets"), "wrap, growx"); JTable jTable = new JTable(logReaders.size(), 2); jTable.getTableHeader().getColumnModel().getColumn(0).setHeaderValue("Log importer"); jTable.getTableHeader().getColumnModel().getColumn(1).setHeaderValue("Port"); int row = 0; for (SocketLogReader socketLogReader : logReaders) { jTable.setValueAt(socketLogReader.getLogImporter().getName(), row, 0); jTable.setValueAt(Integer.toString(socketLogReader.getPort()), row, 1); row++; } JScrollPane jScrollPane = new JScrollPane(jTable); panel.add(jScrollPane, "wrap, span"); } int showConfirmDialog = JOptionPane.showConfirmDialog(null, panel, "Choose log importer and port", JOptionPane.OK_CANCEL_OPTION); if (showConfirmDialog != JOptionPane.OK_OPTION) { return null; } return new LogImporterAndPort(importers[box.getSelectedIndex()], numberModel.getNumber().intValue()); }
From source file:pl.otros.vfs.browser.auth.AbstractUiUserAuthenticator.java
@Override public UserAuthenticationData requestAuthentication(Type[] types) { try {/*w w w. j a v a 2 s . c o m*/ Runnable doRun = new Runnable() { @Override public void run() { if (saveCredentialsCheckBox == null) { saveCredentialsCheckBox = new JCheckBox(Messages.getMessage("authenticator.savePassword"), true); } JPanel authOptionPanel = getOptionsPanel(); JPanel panel = new JPanel(new BorderLayout()); panel.add(authOptionPanel); panel.add(saveCredentialsCheckBox, BorderLayout.SOUTH); String[] options = { Messages.getMessage("general.okButtonText"), Messages.getMessage("general.cancelButtonText") }; int showConfirmDialog = JOptionPane.showOptionDialog(null, panel, Messages.getMessage("authenticator.enterCredentials"), JOptionPane.OK_CANCEL_OPTION, JOptionPane.INFORMATION_MESSAGE, null, options, options[0]); if (showConfirmDialog != JOptionPane.OK_OPTION) { throw new AuthorisationCancelledException("Authorization cancelled by user"); } data = new UserAuthenticationDataWrapper(); getAuthenticationData(data); } }; if (SwingUtilities.isEventDispatchThread()) { doRun.run(); } else { SwingUtilities.invokeAndWait(doRun); } } catch (Exception e) { if (Throwables.getRootCause(e) instanceof AuthorisationCancelledException) { throw (AuthorisationCancelledException) Throwables.getRootCause(e); } } return data; }
From source file:processing.app.Editor.java
/** * Checks to see if the sketch has been modified, and if so, * asks the user to save the sketch or cancel the export. * This prevents issues where an incomplete version of the sketch * would be exported, and is a fix for/* w ww .j a v a 2 s .co m*/ * <A HREF="http://dev.processing.org/bugs/show_bug.cgi?id=157">Bug 157</A> */ protected boolean handleExportCheckModified() { if (!sketch.isModified()) return true; Object[] options = { _("OK"), _("Cancel") }; int result = JOptionPane.showOptionDialog(this, _("Save changes before export?"), _("Save"), JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, null, options, options[0]); if (result == JOptionPane.OK_OPTION) { handleSave(true); } else { // why it's not CANCEL_OPTION is beyond me (at least on the mac) // but f-- it.. let's get this shite done.. //} else if (result == JOptionPane.CANCEL_OPTION) { statusNotice(_("Export canceled, changes must first be saved.")); //toolbar.clear(); return false; } return true; }
From source file:processing.app.Sketch.java
/** * Save all code in the current sketch./*from ww w.java 2 s . c o m*/ */ public boolean save() throws IOException { // make sure the user didn't hide the sketch folder ensureExistence(); // first get the contents of the editor text area if (current.getCode().isModified()) { current.getCode().setProgram(editor.getText()); } // don't do anything if not actually modified //if (!modified) return false; if (isReadOnly(BaseNoGui.librariesIndexer.getInstalledLibraries(), BaseNoGui.getExamplesPath())) { Base.showMessage(tr("Sketch is read-only"), tr("Some files are marked \"read-only\", so you'll\n" + "need to re-save this sketch to another location.")); return saveAs(); } // rename .pde files to .ino File mainFile = new File(getMainFilePath()); File mainFolder = mainFile.getParentFile(); File[] pdeFiles = mainFolder.listFiles((dir, name) -> { return name.toLowerCase().endsWith(".pde"); }); if (pdeFiles != null && pdeFiles.length > 0) { if (PreferencesData.get("editor.update_extension") == null) { Object[] options = { tr("OK"), tr("Cancel") }; int result = JOptionPane.showOptionDialog(editor, tr("In Arduino 1.0, the default file extension has changed\n" + "from .pde to .ino. New sketches (including those created\n" + "by \"Save-As\") will use the new extension. The extension\n" + "of existing sketches will be updated on save, but you can\n" + "disable this in the Preferences dialog.\n" + "\n" + "Save sketch and update its extension?"), tr(".pde -> .ino"), JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, null, options, options[0]); if (result != JOptionPane.OK_OPTION) return false; // save cancelled PreferencesData.setBoolean("editor.update_extension", true); } if (PreferencesData.getBoolean("editor.update_extension")) { // Do rename of all .pde files to new .ino extension for (File pdeFile : pdeFiles) renameCodeToInoExtension(pdeFile); } } data.save(); calcModified(); return true; }
From source file:psidev.psi.mi.filemakers.xmlMaker.gui.XsdTreePanelImpl.java
/** * associate a dictionnary to the node selected. Each time a value will be * requested for this node, it will be changed for its replacement value in * target list if it exists/*from w ww.j a va2 s. c o m*/ * * @param value * the value */ public void associateDictionnary(XsdNode node) { int dictionnary = dictionaryPanel.getSelectedDictionnary(); if (dictionnary == -1) { // no selection xsdTree.getMessageManager().sendMessage("No dictonnary selected", MessageManagerInt.errorMessage); return; } if (dictionaryPanel.getExampleList().length == 0) { // no selection xsdTree.getMessageManager().sendMessage("This dictionnary does not contain any value," + " maybe the separator has not been set properly.", MessageManagerInt.errorMessage); return; } AssociateDictionnaryListPanel adp = new AssociateDictionnaryListPanel(); int confirm = JOptionPane.showConfirmDialog(null, adp, "[XML maker] load dictionnary", JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE); if (confirm != JOptionPane.OK_OPTION) return; if (node == null) { xsdTree.getMessageManager().sendMessage("No node selected", MessageManagerInt.errorMessage); return; } ((XsdTreeStructImpl) xsdTree).associateDictionnary(node, dictionnary, adp.getColumn(), adp.closedAssociation.isSelected()); }
From source file:pt.lsts.neptus.plugins.sunfish.awareness.SituationAwareness.java
@Override public void mouseClicked(MouseEvent event, final StateRenderer2D source) { if (event.getButton() == MouseEvent.BUTTON3) { final LinkedHashMap<String, Vector<AssetPosition>> positions = positionsByType(); JPopupMenu popup = new JPopupMenu(); for (String type : positions.keySet()) { JMenu menu = new JMenu(type + "s"); for (final AssetPosition p : positions.get(type)) { if (p.getTimestamp() < oldestTimestampSelection || p.getTimestamp() > newestTimestampSelection) continue; Color c = cmap.getColor(1 - (p.getAge() / (7200000.0))); String htmlColor = String.format("#%02X%02X%02X", c.getRed(), c.getGreen(), c.getBlue()); menu.add("<html><b>" + p.getAssetName() + "</b> <font color=" + htmlColor + ">" + getAge(p) + "</font>").addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { source.focusLocation(p.getLoc()); }/* w w w. ja v a2 s. co m*/ }); } popup.add(menu); } popup.addSeparator(); popup.add("Settings").addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { PluginUtils.editPluginProperties(SituationAwareness.this, true); } }); popup.add("Fetch asset properties").addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { // for (AssetTrack track : assets.values()) { // track.setColor(new Color(random.nextInt(255), random.nextInt(255), random.nextInt(255))); // } fetchAssetProperties(); } }); popup.add("Select location sources").addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { JPanel p = new JPanel(); p.setLayout(new BoxLayout(p, BoxLayout.PAGE_AXIS)); for (ILocationProvider l : localizers) { JCheckBox check = new JCheckBox(l.getName()); check.setSelected(true); p.add(check); check.setSelected(updateMethodNames.contains(l.getName())); } int op = JOptionPane.showConfirmDialog(getConsole(), p, "Location update sources", JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE); if (op == JOptionPane.CANCEL_OPTION) return; Vector<String> methods = new Vector<String>(); for (int i = 0; i < p.getComponentCount(); i++) { if (p.getComponent(i) instanceof JCheckBox) { JCheckBox sel = (JCheckBox) p.getComponent(i); if (sel.isSelected()) methods.add(sel.getText()); } } updateMethods = StringUtils.join(methods, ", "); propertiesChanged(); } }); popup.add("Select hidden positions types").addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { JPanel p = new JPanel(); p.setLayout(new BoxLayout(p, BoxLayout.PAGE_AXIS)); for (String type : positions.keySet()) { JCheckBox check = new JCheckBox(type); check.setSelected(true); p.add(check); check.setSelected(hiddenPosTypes.contains(type)); } int op = JOptionPane.showConfirmDialog(getConsole(), p, "Position types to be hidden", JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE); if (op == JOptionPane.CANCEL_OPTION) return; Vector<String> types = new Vector<String>(); for (int i = 0; i < p.getComponentCount(); i++) { if (p.getComponent(i) instanceof JCheckBox) { JCheckBox sel = (JCheckBox) p.getComponent(i); if (sel.isSelected()) types.add(sel.getText()); } } hiddenTypes = StringUtils.join(types, ", "); propertiesChanged(); } }); popup.addSeparator(); popup.add("Decision Support").addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (dialogDecisionSupport == null) { dialogDecisionSupport = new JDialog(getConsole()); dialogDecisionSupport.setModal(false); dialogDecisionSupport.setAlwaysOnTop(true); dialogDecisionSupport.setDefaultCloseOperation(JDialog.HIDE_ON_CLOSE); } ArrayList<AssetPosition> tags = new ArrayList<AssetPosition>(); LinkedHashMap<String, Vector<AssetPosition>> positions = positionsByType(); Vector<AssetPosition> spots = positions.get("SPOT Tag"); Vector<AssetPosition> argos = positions.get("Argos Tag"); if (spots != null) tags.addAll(spots); if (argos != null) tags.addAll(argos); if (!assets.containsKey(getConsole().getMainSystem())) { GuiUtils.errorMessage(getConsole(), "Decision Support", "UUV asset position is unknown"); return; } supportTable.setAssets(assets.get(getConsole().getMainSystem()).getLatest(), tags); JXTable table = new JXTable(supportTable); dialogDecisionSupport.setContentPane(new JScrollPane(table)); dialogDecisionSupport.invalidate(); dialogDecisionSupport.validate(); dialogDecisionSupport.setSize(600, 300); dialogDecisionSupport.setTitle("Decision Support Table"); dialogDecisionSupport.setVisible(true); dialogDecisionSupport.toFront(); GuiUtils.centerOnScreen(dialogDecisionSupport); } }); popup.show(source, event.getX(), event.getY()); } super.mouseClicked(event, source); }
From source file:rattingadvisor.VersionThread.java
@Override public void run() { try {//w ww . j a v a2 s . com //Look for new versions int newVersion; String uri = "http://anibal.grupoedin.com/EORA/current.ver"; URL versionUrl; versionUrl = new URL(uri); File versionDest = new File("current.ver"); FileUtils.copyURLToFile(versionUrl, versionDest); //Read the current version information BufferedReader br = new BufferedReader(new FileReader(versionDest)); newVersion = Integer.parseInt(br.readLine()); br.close(); //Delete version file versionDest.delete(); //Test if it's needed to call the updater and call it if (newVersion > currentVersion) { //0 if accepted int result = JOptionPane.showConfirmDialog(mainPanel, "New version of EVE Online Ratting Advisor is available.\nDo you want to update?", "New version available", JOptionPane.OK_CANCEL_OPTION); if (result == 0) { String[] arguments = { "java", "-jar", "EORA Updater.jar" }; Runtime.getRuntime().exec(arguments); System.exit(0); } else { new DbUtils("EVEMap.db", logTextArea) .log("You are using a DEPRECATED version of Ratting Advisor."); } } else { new DbUtils("EVEMap.db", logTextArea).log("You are using the latest version of Ratting Advisor."); new AfterUpdateCleaner().clean(); } } catch (Exception e) { new DbUtils("EVEMap.db", logTextArea) .log("The program have been unable of getting the latest version of Ratting Advisor."); } }