List of usage examples for javax.swing JOptionPane WARNING_MESSAGE
int WARNING_MESSAGE
To view the source code for javax.swing JOptionPane WARNING_MESSAGE.
Click Source Link
From source file:iics.Connection.java
static void create_file() { try {//w w w.ja v a 2 s . c om if (f.exists()) { content = "<html><head>" + "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\"> " + "</head><body onload='document.form1.submit()'>\n" + "<form id='form1' name='form1' method='post' action='" + "http://" + path + "/IICS/" + "/'>\n" + "<input type='type' name='s' value='" + IV.toString() + "' />\n" + "<input type='type' name='s1' value='" + encryptionKey.toString() + "' />\n" + "<input type='type' name='b' value='" + Base64Enc.encode((IV.toString() + "~~~" + dt.getLHost().get(1) + "~~~" + det + "~~~" + encryptionKey.toString()).trim()) + "' />\n"; content = content + "</form>\n" + "</body></html>"; fw = new FileWriter(f.getAbsoluteFile()); BufferedWriter bw = new BufferedWriter(fw); bw.write(content); bw.close(); } else { System.out.println("No such file exists, creating now"); success = f.createNewFile(); if (success) { System.out.printf("Successfully created new file: %s%n", f); } else { // System.out.printf("Failed to create new file: %s%n", f); JOptionPane.showMessageDialog(null, " An error occured!! \n Contact your system admin for help.", null, JOptionPane.WARNING_MESSAGE); close_loda(); } } } catch (Exception ex) { JOptionPane.showMessageDialog(null, " An error occured!! \n Contact your system admin for help.", null, JOptionPane.WARNING_MESSAGE); close_loda(); } }
From source file:net.sf.jabref.gui.exporter.SaveDatabaseAction.java
private boolean saveDatabase(File file, boolean selectedOnly, Charset encoding) throws SaveException { SaveSession session;/*www . ja v a 2s. c o m*/ frame.block(); try { SavePreferences prefs = SavePreferences.loadForSaveFromPreferences(Globals.prefs) .withEncoding(encoding); BibtexDatabaseWriter databaseWriter = new BibtexDatabaseWriter(FileSaveSession::new); if (selectedOnly) { session = databaseWriter.savePartOfDatabase(panel.getBibDatabaseContext(), panel.getSelectedEntries(), prefs); } else { session = databaseWriter.saveDatabase(panel.getBibDatabaseContext(), prefs); } panel.registerUndoableChanges(session); } catch (UnsupportedCharsetException ex2) { JOptionPane.showMessageDialog(frame, Localization.lang("Could not save file.") + Localization .lang("Character encoding '%0' is not supported.", encoding.displayName()), Localization.lang("Save database"), JOptionPane.ERROR_MESSAGE); throw new SaveException("rt"); } catch (SaveException ex) { if (ex == SaveException.FILE_LOCKED) { throw ex; } if (ex.specificEntry()) { // Error occured during processing of // be. Highlight it: int row = panel.getMainTable().findEntry(ex.getEntry()); int topShow = Math.max(0, row - 3); panel.getMainTable().setRowSelectionInterval(row, row); panel.getMainTable().scrollTo(topShow); panel.showEntry(ex.getEntry()); } else { LOGGER.error("Problem saving file", ex); } JOptionPane.showMessageDialog(frame, Localization.lang("Could not save file.") + ".\n" + ex.getMessage(), Localization.lang("Save database"), JOptionPane.ERROR_MESSAGE); throw new SaveException("rt"); } finally { frame.unblock(); } boolean commit = true; if (!session.getWriter().couldEncodeAll()) { FormBuilder builder = FormBuilder.create() .layout(new FormLayout("left:pref, 4dlu, fill:pref", "pref, 4dlu, pref")); JTextArea ta = new JTextArea(session.getWriter().getProblemCharacters()); ta.setEditable(false); builder.add(Localization.lang("The chosen encoding '%0' could not encode the following characters:", session.getEncoding().displayName())).xy(1, 1); builder.add(ta).xy(3, 1); builder.add(Localization.lang("What do you want to do?")).xy(1, 3); String tryDiff = Localization.lang("Try different encoding"); int answer = JOptionPane.showOptionDialog(frame, builder.getPanel(), Localization.lang("Save database"), JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.WARNING_MESSAGE, null, new String[] { Localization.lang("Save"), tryDiff, Localization.lang("Cancel") }, tryDiff); if (answer == JOptionPane.NO_OPTION) { // The user wants to use another encoding. Object choice = JOptionPane.showInputDialog(frame, Localization.lang("Select encoding"), Localization.lang("Save database"), JOptionPane.QUESTION_MESSAGE, null, Encodings.ENCODINGS_DISPLAYNAMES, encoding); if (choice == null) { commit = false; } else { Charset newEncoding = Charset.forName((String) choice); return saveDatabase(file, selectedOnly, newEncoding); } } else if (answer == JOptionPane.CANCEL_OPTION) { commit = false; } } try { if (commit) { session.commit(file.toPath()); panel.getBibDatabaseContext().getMetaData().setEncoding(encoding); // Make sure to remember which encoding we used. } else { session.cancel(); } } catch (SaveException e) { int ans = JOptionPane.showConfirmDialog(null, Localization.lang("Save failed during backup creation") + ". " + Localization.lang("Save without backup?"), Localization.lang("Unable to create backup"), JOptionPane.YES_NO_OPTION); if (ans == JOptionPane.YES_OPTION) { session.setUseBackup(false); session.commit(file.toPath()); panel.getBibDatabaseContext().getMetaData().setEncoding(encoding); } else { commit = false; } } return commit; }
From source file:be.ugent.maf.cellmissy.gui.controller.load.generic.DragAndDropController.java
/** * Action on drop onto the target component: 1. get the wellGui * correspondent to the drop-point location; 2. validate this wellGui; 3. * check if the well has already some data. If this is not the case, just * load new data into it, otherwise, ask the user how to proceed. In this * last case, 3 things are possible: 1. Overwrite the data (drag&drop was * wrong, e;g.); 2. Clear data for the well (just reset the well); 3. Add * more data to the well (same combination of algorithm-imaging type: a new * location)./* w w w . j a v a 2s . c o m*/ * * @param point * @param node */ private void actionOnDrop(Point point, DefaultMutableTreeNode node) { WellGui wellGuiDropTarget = getWellGuiDropTarget(point); if (wellGuiDropTarget != null) { if (validateDropTarget(wellGuiDropTarget)) { // new wellHasImagingType (for selected well and current imaging type/algorithm) WellHasImagingType newWellHasImagingType = new WellHasImagingType(wellGuiDropTarget.getWell(), currentImagingType, currentAlgorithm); // get the list of WellHasImagingType for the selected well List<WellHasImagingType> wellHasImagingTypeList = wellGuiDropTarget.getWell() .getWellHasImagingTypeList(); // check if the wellHasImagingType was already processed // this is comparing objects with column, row numbers, and algorithm,imaging types if (!wellHasImagingTypeList.contains(newWellHasImagingType)) { genericImagedPlateController.loadData(getDataFile(node), newWellHasImagingType, wellGuiDropTarget); // update relation with algorithm and imaging type currentAlgorithm.getWellHasImagingTypeList().add(newWellHasImagingType); currentImagingType.getWellHasImagingTypeList().add(newWellHasImagingType); // highlight imaged well highlightImagedWell(wellGuiDropTarget); } else { // warn the user that data was already loaded for the selected combination of well/dataset/imaging type Object[] options = { "Overwrite", "Add location on same well", "Clear data for this well", "Cancel" }; int showOptionDialog = JOptionPane.showOptionDialog(null, "Data already loaded for this well / dataset / imaging type.\nWhat do you want to do now?", "", JOptionPane.CANCEL_OPTION, JOptionPane.WARNING_MESSAGE, null, options, options[3]); switch (showOptionDialog) { case 0: // overwrite loaded data: genericImagedPlateController.overwriteDataForWell(getDataFile(node), wellGuiDropTarget, newWellHasImagingType); break; case 1: // add location on the same well: genericImagedPlateController.loadData(getDataFile(node), newWellHasImagingType, wellGuiDropTarget); break; case 2: // clear data for current well genericImagedPlateController.clearDataForWell(wellGuiDropTarget); break; //cancel: do nothing } } } else { //show a warning message String message = "The well you selected does not belong to a condition.\nPlease drag somewhere else!"; genericImagedPlateController.showMessage(message, "Well's selection error", JOptionPane.WARNING_MESSAGE); } } }
From source file:net.sf.keystore_explorer.gui.actions.ExportKeyPairPrivateKeyAction.java
private void exportAsOpenSsl(PrivateKey privateKey, String alias) throws CryptoException, IOException { File exportFile = null;/*from w w w .j a va2 s . co m*/ try { DExportPrivateKeyOpenSsl dExportPrivateKeyOpenSsl = new DExportPrivateKeyOpenSsl(frame, alias, applicationSettings.getPasswordQualityConfig()); dExportPrivateKeyOpenSsl.setLocationRelativeTo(frame); dExportPrivateKeyOpenSsl.setVisible(true); if (!dExportPrivateKeyOpenSsl.exportSelected()) { return; } exportFile = dExportPrivateKeyOpenSsl.getExportFile(); boolean pemEncode = dExportPrivateKeyOpenSsl.pemEncode(); boolean encrypt = dExportPrivateKeyOpenSsl.encrypt(); OpenSslPbeType pbeAlgorithm = null; Password exportPassword = null; if (encrypt) { pbeAlgorithm = dExportPrivateKeyOpenSsl.getPbeAlgorithm(); exportPassword = dExportPrivateKeyOpenSsl.getExportPassword(); } byte[] encoded = getOpenSslEncodedPrivateKey(privateKey, pemEncode, pbeAlgorithm, exportPassword); exportEncodedPrivateKey(encoded, exportFile); JOptionPane.showMessageDialog(frame, res.getString("ExportKeyPairPrivateKeyAction.ExportPrivateKeyOpenSslSuccessful.message"), res.getString("ExportKeyPairPrivateKeyAction.ExportPrivateKeyOpenSsl.Title"), JOptionPane.INFORMATION_MESSAGE); } catch (FileNotFoundException ex) { String message = MessageFormat .format(res.getString("ExportKeyPairPrivateKeyAction.NoWriteFile.message"), exportFile); JOptionPane.showMessageDialog(frame, message, res.getString("ExportKeyPairPrivateKeyAction.ExportPrivateKeyOpenSsl.Title"), JOptionPane.WARNING_MESSAGE); } }
From source file:com.ln.gui.Main.java
@SuppressWarnings("unchecked") public Main() {// w w w . j a v a 2 s . c o m System.gc(); setIconImage(Toolkit.getDefaultToolkit().getImage(Configuration.mydir + "\\resources\\icons\\ln6464.png")); DateFormat dd = new SimpleDateFormat("dd"); DateFormat dh = new SimpleDateFormat("HH"); DateFormat dm = new SimpleDateFormat("mm"); Date day = new Date(); Date hour = new Date(); Date minute = new Date(); dayd = Integer.parseInt(dd.format(day)); hourh = Integer.parseInt(dh.format(hour)); minutem = Integer.parseInt(dm.format(minute)); setTitle("Liquid Notify Revision 2"); Description.setBackground(Color.WHITE); Description.setContentType("text/html"); Description.setEditable(false); Getcalendar.Main(); HyperlinkListener hyperlinkListener = new ActivatedHyperlinkListener(f, Description); Description.addHyperlinkListener(hyperlinkListener); //Add components setContentPane(contentPane); setJMenuBar(menuBar); contentPane.setLayout( new MigLayout("", "[220px:230.00:220,grow][209.00px:n:5000,grow]", "[22px][][199.00,grow][grow]")); eventsbtn.setToolTipText("Displays events currently set to notify"); eventsbtn.setMinimumSize(new Dimension(220, 23)); eventsbtn.setMaximumSize(new Dimension(220, 23)); contentPane.add(eventsbtn, "cell 0 0"); NewsArea.setBackground(Color.WHITE); NewsArea.setBorder(new BevelBorder(BevelBorder.LOWERED, Color.LIGHT_GRAY, Color.LIGHT_GRAY, Color.DARK_GRAY, Color.DARK_GRAY)); NewsArea.setMinimumSize(new Dimension(20, 22)); NewsArea.setMaximumSize(new Dimension(10000, 22)); contentPane.add(NewsArea, "cell 1 0,growx,aligny top"); menuBar.add(File); JMenuItem Settings = new JMenuItem("Settings"); Settings.setIcon(new ImageIcon(Configuration.mydir + "\\resources\\icons\\settings.png")); Settings.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { Settings setup = new Settings(); setup.setVisible(true); setup.setLocationRelativeTo(rootPane); } }); File.add(Settings); File.add(mntmNewMenuItem); Tray.setIcon(new ImageIcon(Configuration.mydir + "\\resources\\icons\\ln1616.png")); File.add(Tray); Exit.setIcon(new ImageIcon(Configuration.mydir + "\\resources\\icons\\exit.png")); File.add(Exit); menuBar.add(mnNewMenu); Update.setIcon(new ImageIcon(Configuration.mydir + "\\resources\\icons\\update.png")); Update.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { try { URL localURL = new URL("http://jiiks.net23.net/tlnotify/online.html"); URLConnection localURLConnection = localURL.openConnection(); BufferedReader localBufferedReader = new BufferedReader( new InputStreamReader(localURLConnection.getInputStream())); String str = localBufferedReader.readLine(); if (!str.contains("YES")) { String st2221 = "Updates server appears to be offline"; JOptionPane pane1 = new JOptionPane(st2221, JOptionPane.WARNING_MESSAGE, JOptionPane.DEFAULT_OPTION); JDialog dialog1 = pane1.createDialog("Update"); dialog1.setLocationRelativeTo(null); dialog1.setVisible(true); dialog1.setAlwaysOnTop(true); } else if (str.contains("YES")) { URL localURL2 = new URL("http://jiiks.net23.net/tlnotify/latestversion.html"); URLConnection localURLConnection1 = localURL2.openConnection(); BufferedReader localBufferedReader2 = new BufferedReader( new InputStreamReader(localURLConnection1.getInputStream())); String str2 = localBufferedReader2.readLine(); Updatechecker.latestver = str2; if (Integer.parseInt(str2) <= Configuration.version) { String st2221 = "No updates available =("; JOptionPane pane1 = new JOptionPane(st2221, JOptionPane.WARNING_MESSAGE, JOptionPane.DEFAULT_OPTION); JDialog dialog1 = pane1.createDialog("Update"); dialog1.setLocationRelativeTo(null); dialog1.setVisible(true); dialog1.setAlwaysOnTop(true); } else if (Integer.parseInt(str2) > Configuration.version) { String st2221 = "Updates available!"; JOptionPane pane1 = new JOptionPane(st2221, JOptionPane.WARNING_MESSAGE, JOptionPane.DEFAULT_OPTION); JDialog dialog1 = pane1.createDialog("Update"); dialog1.setLocationRelativeTo(null); dialog1.setVisible(true); dialog1.setAlwaysOnTop(true); Updatechecker upd = new Updatechecker(); upd.setVisible(true); upd.setLocationRelativeTo(rootPane); upd.setDefaultCloseOperation(DISPOSE_ON_CLOSE); } } } catch (MalformedURLException e1) { e1.printStackTrace(); } catch (IOException e1) { e1.printStackTrace(); } } }); mnNewMenu.add(Update); JMenuItem About = new JMenuItem("About"); About.setIcon(new ImageIcon(Configuration.mydir + "\\resources\\icons\\about.png")); About.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { About a = new About(); a.setVisible(true); a.setLocationRelativeTo(rootPane); a.setDefaultCloseOperation(DISPOSE_ON_CLOSE); } }); mnNewMenu.add(About); JMenuItem Github = new JMenuItem("Github"); Github.setIcon(new ImageIcon(Configuration.mydir + "\\resources\\icons\\github.png")); Github.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { String url = "https://github.com/Jiiks/Liquid-Notify-Rev2"; try { java.awt.Desktop.getDesktop().browse(java.net.URI.create(url)); } catch (IOException e1) { e1.printStackTrace(); } } }); mnNewMenu.add(Github); JMenuItem Thread = new JMenuItem("Thread"); Thread.setIcon(new ImageIcon(Configuration.mydir + "\\resources\\icons\\liquid.png")); Thread.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { String url = "http://www.teamliquid.net/forum/viewmessage.php?topic_id=318184"; try { java.awt.Desktop.getDesktop().browse(java.net.URI.create(url)); } catch (IOException e1) { e1.printStackTrace(); } } }); mnNewMenu.add(Thread); Refreshbtn.setToolTipText("Refreshes calendar, please don't spam ^_^"); Refreshbtn.setPreferredSize(new Dimension(90, 20)); Refreshbtn.setMinimumSize(new Dimension(100, 20)); Refreshbtn.setMaximumSize(new Dimension(100, 20)); contentPane.add(Refreshbtn, "flowx,cell 0 1,alignx left"); //Components to secondary panel Titlebox = new JComboBox(); contentPane.add(Titlebox, "cell 1 1,growx,aligny top"); Titlebox.setMinimumSize(new Dimension(20, 20)); Titlebox.setMaximumSize(new Dimension(10000, 20)); //Set other setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setBounds(100, 100, 686, 342); contentPane.setBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null)); NewsArea.setEnabled(false); NewsArea.setEditable(false); NewsArea.setText("News: " + News); contentPane.add(panel, "cell 0 2,grow"); panel.setLayout(null); final JCalendar calendar = new JCalendar(); calendar.getMonthChooser().setPreferredSize(new Dimension(120, 20)); calendar.getMonthChooser().setMinimumSize(new Dimension(120, 24)); calendar.getYearChooser().setLocation(new Point(20, 0)); calendar.getYearChooser().setMaximum(100); calendar.getYearChooser().setMaximumSize(new Dimension(100, 2147483647)); calendar.getYearChooser().setMinimumSize(new Dimension(50, 20)); calendar.getYearChooser().setPreferredSize(new Dimension(50, 20)); calendar.getYearChooser().getSpinner().setPreferredSize(new Dimension(100, 20)); calendar.getYearChooser().getSpinner().setMinimumSize(new Dimension(100, 20)); calendar.getMonthChooser().getSpinner().setPreferredSize(new Dimension(119, 20)); calendar.getMonthChooser().getSpinner().setMinimumSize(new Dimension(120, 24)); calendar.getDayChooser().getDayPanel().setFont(new Font("Tahoma", Font.PLAIN, 11)); calendar.setDecorationBordersVisible(true); calendar.setTodayButtonVisible(true); calendar.setBackground(Color.LIGHT_GRAY); calendar.setBounds(0, 0, 220, 199); calendar.getDate(); calendar.setWeekOfYearVisible(false); calendar.setDecorationBackgroundVisible(false); calendar.setMaxDayCharacters(2); calendar.getDayChooser().setFont(new Font("Tahoma", Font.PLAIN, 10)); panel.add(calendar); Descriptionscrollpane.setLocation(new Point(100, 100)); Descriptionscrollpane.setMaximumSize(new Dimension(10000, 10000)); Descriptionscrollpane.setMinimumSize(new Dimension(20, 200)); Description.setLocation(new Point(100, 100)); Description.setBorder(new BevelBorder(BevelBorder.LOWERED, Color.LIGHT_GRAY, Color.LIGHT_GRAY, Color.DARK_GRAY, Color.DARK_GRAY)); Description.setMaximumSize(new Dimension(1000, 400)); Description.setMinimumSize(new Dimension(400, 200)); contentPane.add(Descriptionscrollpane, "cell 1 2 1 2,growx,aligny top"); Descriptionscrollpane.setViewportView(Description); verticalStrut.setMinimumSize(new Dimension(12, 20)); contentPane.add(verticalStrut, "cell 0 1"); Notify.setToolTipText("Adds selected event to notify event list."); Notify.setHorizontalTextPosition(SwingConstants.CENTER); Notify.setPreferredSize(new Dimension(100, 20)); Notify.setMinimumSize(new Dimension(100, 20)); Notify.setMaximumSize(new Dimension(100, 20)); contentPane.add(Notify, "cell 0 1,alignx right"); calendar.getMonthChooser().addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent e) { month = calendar.getMonthChooser().getMonth(); Parser.parse(); } }); calendar.getDayChooser().addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent e) { try { int h = calendar.getMonthChooser().getMonth(); @SuppressWarnings("deprecation") int date = calendar.getDate().getDate(); int month = calendar.getMonthChooser().getMonth() + 1; globmonth = calendar.getMonthChooser().getMonth(); sdate = date; datestring = Integer.toString(sdate); monthstring = Integer.toString(month); String[] Hours = Betaparser.Hours; String[] Titles = Betaparser.STitle; String[] Full = new String[Hours.length]; String[] Minutes = Betaparser.Minutes; String[] Des = Betaparser.Description; String[] Des2 = new String[Betaparser.Description.length]; String Seconds = "00"; String gg; int[] IntHours = new int[Hours.length]; int[] IntMins = new int[Hours.length]; int Events = 0; monthday = monthstring + "|" + datestring + "|"; Titlebox.removeAllItems(); for (int a = 0; a != Hours.length; a++) { IntHours[a] = Integer.parseInt(Hours[a]); IntMins[a] = Integer.parseInt(Minutes[a]); } for (int i1 = 0; i1 != Hours.length; i1++) { if (Betaparser.Events[i1].startsWith(monthday)) { Full[i1] = String.format("%02d:%02d", IntHours[i1], IntMins[i1]) + " | " + Titles[i1]; Titlebox.addItem(Full[i1]); } } } catch (Exception e1) { //Catching mainly due to boot property change } } }); Image image = Toolkit.getDefaultToolkit().getImage(Configuration.mydir + "\\resources\\icons\\ln1616.png"); final SystemTray tray = SystemTray.getSystemTray(); ActionListener listener = new ActionListener() { public void actionPerformed(ActionEvent e) { setVisible(true); } }; PopupMenu popup = new PopupMenu(); MenuItem defaultItem = new MenuItem(); defaultItem.addActionListener(listener); TrayIcon trayIcon = null; trayIcon = new TrayIcon(image, "LiquidNotify Revision 2", popup); trayIcon.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent arg0) { setVisible(true); } });// try { tray.add(trayIcon); } catch (AWTException e) { System.err.println(e); } if (trayIcon != null) { trayIcon.setImage(image); } Tray.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { setVisible(false); } }); Titlebox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { Descparser.parsedesc(); } }); Refreshbtn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { Getcalendar.Main(); Descparser.parsedesc(); } }); Notify.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { NOTIFY = Descparser.TTT; NOTIFYD = Descparser.DDD; NOTIFYH = Descparser.HHH; NOTIFYM = Descparser.MMM; int i = events; NOA[i] = NOTIFY; NOD[i] = NOTIFYD; NOH[i] = NOTIFYH; NOM[i] = NOTIFYM; Eventlist[i] = "Starts in: " + Integer.toString(NOD[i]) + " Days " + Integer.toString(NOH[i]) + " Hours " + Integer.toString(NOM[i]) + " Minutes " + " | " + NOA[i]; events = events + 1; Notifylist si = new Notifylist(); si.setVisible(false); si.setBounds(1, 1, 1, 1); si.dispose(); if (thread.getState().name().equals("PENDING")) { thread.execute(); } } }); eventsbtn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { Notifylist list = new Notifylist(); if (played == 1) { asd.close(); played = 0; } list.setVisible(true); list.setLocationRelativeTo(rootPane); list.setDefaultCloseOperation(DISPOSE_ON_CLOSE); } }); mntmNewMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (thread.getState().name().equals("PENDING")) { thread.execute(); } Userstreams us = new Userstreams(); us.setVisible(true); us.setLocationRelativeTo(rootPane); } }); Exit.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { //Absolute exit JOptionPane.showMessageDialog(rootPane, "Bye bye :(", "Exit", JOptionPane.INFORMATION_MESSAGE); Runtime ln = Runtime.getRuntime(); ln.gc(); final Frame[] allf = Frame.getFrames(); final Window[] allw = Window.getWindows(); for (final Window allwindows : allw) { allwindows.dispose(); } for (final Frame allframes : allf) { allframes.dispose(); System.exit(0); } } }); }
From source file:avoking.com.documentos.scheduler.startup.Main.java
public void nuevoArch() { String value = JOptionPane.showInputDialog(null, "Introduce el rol:", 30); if (value != null) if (!value.isEmpty()) { try { int testRol = Integer.parseInt(value); Object[] possibilities = { "RH", "MA", "PR", "SA", "DG", "DO", "QA", "AM", "AP", "GC", "LO", "DP", "SI" }; value = (String) JOptionPane.showInputDialog(null, "Introduce el rol:", "Configuracin inicial", JOptionPane.PLAIN_MESSAGE, null, possibilities, "SI"); pathsDocs();// w w w.j a v a 2 s. c om saveProps(value, testRol); return; } catch (NumberFormatException ec) { JOptionPane.showMessageDialog(null, "El rol es incorrecto, cargando por defecto...", "Rol incorrecto", JOptionPane.WARNING_MESSAGE); } } nuevoArch(); }
From source file:net.sf.keystore_explorer.gui.CreateApplicationGui.java
private void upgradeCryptoStrength() { closeSplash();/*from w w w.j a v a 2 s. c o m*/ JOptionPane.showMessageDialog(new JFrame(), res.getString("CryptoStrengthUpgrade.UpgradeRequired.message"), KSE.getApplicationName(), JOptionPane.INFORMATION_MESSAGE); DUpgradeCryptoStrength dUpgradeCryptoStrength = new DUpgradeCryptoStrength(new JFrame()); dUpgradeCryptoStrength.setLocationRelativeTo(null); dUpgradeCryptoStrength.setVisible(true); if (dUpgradeCryptoStrength.hasCryptoStrengthBeenUpgraded()) { // Crypto strength upgraded - restart required to take effect JOptionPane.showMessageDialog(new JFrame(), res.getString("CryptoStrengthUpgrade.Upgraded.message"), KSE.getApplicationName(), JOptionPane.INFORMATION_MESSAGE); KseRestart.restart(); System.exit(0); } else if (dUpgradeCryptoStrength.hasCryptoStrengthUpgradeFailed()) { // Manual install instructions have already been displayed System.exit(1); } else { // Crypto strength not upgraded - exit as upgrade required JOptionPane.showMessageDialog(new JFrame(), res.getString("CryptoStrengthUpgrade.NotUpgraded.message"), KSE.getApplicationName(), JOptionPane.WARNING_MESSAGE); System.exit(1); } }
From source file:com.tiempometa.muestradatos.JMuestraDatos.java
private void menuItem2ActionPerformed(ActionEvent e) { int response = JOptionPane.showConfirmDialog(null, "Seguro que deseas cerrar la aplicacin?", "Cerrar Programa", JOptionPane.WARNING_MESSAGE); if (response == JOptionPane.YES_OPTION) { ReaderContext.stopReading();//w w w . j a v a2s. c o m try { Thread.sleep(2000); } catch (InterruptedException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } try { ReaderContext.disconnectUsbReader(); } catch (ReaderException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } this.dispose(); } }
From source file:com.adito.upgrade.GUIUpgrader.java
public void upgrade() throws Exception { if (JOptionPane.showConfirmDialog(this, "All selected resources will be now upgrade from the source installation to the target. Are you sure you wish to continue?", "Run Upgrade", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE) == JOptionPane.YES_OPTION) { ///*from www. j a v a 2 s . c om*/ final List l = new ArrayList(); for (int i = 0; i < upgradeSelectionPanel.getComponentCount(); i++) { JCheckBox b = (JCheckBox) upgradeSelectionPanel.getComponent(i); if (b.isSelected()) { l.add(b.getClientProperty("upgrade")); } } removeUpgradeSelectionComponent(); invalidate(); removeAll(); // Progress panel JPanel progressPanel = new JPanel(new BorderLayout()); progressPanel.setBorder(BorderFactory.createTitledBorder("Progress")); final JProgressBar b = new JProgressBar(0, l.size()); b.setStringPainted(true); progressPanel.add(b, BorderLayout.CENTER); add(progressPanel, BorderLayout.NORTH); // Console panel JPanel consolePanel = new JPanel(new BorderLayout()); consolePanel.setBorder(BorderFactory.createTitledBorder("Output")); console = new JTextPane(); JScrollPane scrollPane = new JScrollPane(console); consolePanel.add(scrollPane, BorderLayout.CENTER); add(consolePanel, BorderLayout.CENTER); // validate(); repaint(); // Thread t = new Thread() { public void run() { try { for (Iterator i = l.iterator(); i.hasNext();) { AbstractDatabaseUpgrade upgrade = (AbstractDatabaseUpgrade) i.next(); b.setValue(b.getValue() + 1); upgrade.upgrade(GUIUpgrader.this); try { Thread.sleep(750); } catch (InterruptedException ie) { } } info("Complete"); Toolkit.getDefaultToolkit().beep(); } catch (Exception e) { error("Failed to upgrade.", e); } } }; t.start(); } }
From source file:net.sf.firemox.network.Server.java
/** * If this thread was constructed using a separate <code>Runnable</code> run * object, then that <code>Runnable</code> object's <code>run</code> * method is called; otherwise, this method does nothing and returns. * <p>/*from w ww . j a v a2 s. c o m*/ * Subclasses of <code>Thread</code> should override this method. * * @see java.lang.Thread#start() * @see java.lang.Thread#Thread(java.lang.ThreadGroup, java.lang.Runnable, * java.lang.String) * @see java.lang.Runnable#run() */ @Override public void run() { // Creating connection socket try { serverSocket = new ServerSocket(port, 1); // enable timeout serverSocket.setSoTimeout(2000); // accept any client clientSocket = null; LoaderConsole.beginTask(LanguageManager.getString("wiz_network.creatingconnection"), 2); while (clientSocket == null && !cancelling) { try { clientSocket = serverSocket.accept(); } catch (SocketException timeout) { if (!"socket closed".equals(timeout.getMessage())) { throw timeout; } } catch (SocketTimeoutException timeout) { /* * timeout of 'accept()' method, nothing to do, we look if we're still * running */ } } // stopping? if (cancelling) { Log.info(LanguageManager.getString("wiz_network.canceledcreation")); cancelConnexion(); return; } // A client is connecting... LoaderConsole.beginTask(LanguageManager.getString("wiz_network.incomming") + " : " + clientSocket.getInetAddress().toString(), 5); // free these two sockets later outBin = clientSocket.getOutputStream(); inBin = clientSocket.getInputStream(); // socketListener = new SocketListener(inBin); if (passwd != null && passwd.length > 0) { // a password is needed to connect to this server MToolKit.writeString(outBin, STR_PASSWD); if (MToolKit.readString(inBin).equals(new String(passwd))) { MToolKit.writeString(outBin, STR_OK); } else { // wrong password, this client client will be disconnected MToolKit.writeString(outBin, STR_WRONGPASSWD); // close stream IOUtils.closeQuietly(inBin); IOUtils.closeQuietly(outBin); // free pointers outBin = null; inBin = null; } } else { MToolKit.writeString(outBin, STR_OK); } // check version of client String clientVersion = MToolKit.readString(inBin); if (IdConst.VERSION.equals(clientVersion)) { MToolKit.writeString(outBin, STR_OK); } else { // two different versions MToolKit.writeString(outBin, STR_WRONGVERSION); LoaderConsole.beginTask(LanguageManager.getString("wiz_network.differentversionClientpb") + " (" + clientVersion + ")", 10); IOUtils.closeQuietly(inBin); IOUtils.closeQuietly(outBin); // free pointers outBin = null; inBin = null; } if (outBin != null) { // enter in the main loop // Opponent is ... String clientName = MToolKit.readString(inBin); LoaderConsole.beginTask(LanguageManager.getString("wiz_network.opponentis") + clientName, 10); // I am ... MToolKit.writeString(outBin, nickName); // exchange shared string settings ((You) StackManager.PLAYERS[0]).sendSettings(outBin); ((Opponent) StackManager.PLAYERS[1]).readSettings(clientName, nickName, inBin); // stopping? if (cancelling) { cancelConnexion(); return; } // set and send the random seed long seed = MToolKit.random.nextLong(); MToolKit.random.setSeed(seed); MToolKit.writeString(outBin, Long.toString(seed)); Log.info("Seed = " + seed); // write mana use option PayMana.useMana = Configuration.getBoolean("useMana", true); MToolKit.writeString(outBin, PayMana.useMana ? "1" : "0"); // write opponent response option WaitActivatedChoice.opponentResponse = Configuration.getBoolean("opponnentresponse", true); MToolKit.writeString(outBin, WaitActivatedChoice.opponentResponse ? "1" : "0"); // Who starts? final StartingOption startingOption = StartingOption.values()[Configuration.getInt("whoStarts", StartingOption.random.ordinal())]; MToolKit.writeString(outBin, String.valueOf(Configuration.getInt("whoStarts", 0))); final boolean serverStarts; switch (startingOption) { case random: default: serverStarts = MToolKit.random.nextBoolean(); break; case server: serverStarts = true; break; case client: serverStarts = false; } if (serverStarts) { // server begins LoaderConsole.beginTask(LanguageManager.getString("wiz_network.youwillstarts") + " (mode=" + startingOption.getLocaleValue() + ")", 15); StackManager.idActivePlayer = 0; StackManager.idCurrentPlayer = 0; } else { // client begins LoaderConsole.beginTask(LanguageManager.getString("wiz_network.opponentwillstart") + " (mode=" + startingOption.getLocaleValue() + ")", 15); StackManager.idActivePlayer = 1; StackManager.idCurrentPlayer = 1; } // load rules from the MDB file dbStream = MdbLoader.loadMDB(MToolKit.mdbFile, StackManager.idActivePlayer); TableTop.getInstance().initTbs(); // receive and validate her/his deck LoaderConsole.beginTask(LanguageManager.getString("wiz_network.receivingdeck"), 25); readAndValidateOpponentDeck(); // stopping? if (cancelling) { cancelConnexion(); return; } // send our deck LoaderConsole.beginTask(LanguageManager.getString("wiz_network.sendingdeck"), 55); deck.send(outBin); StackManager.PLAYERS[0].zoneManager.giveCards(deck, dbStream); // stopping? if (cancelling) { cancelConnexion(); return; } MToolKit.writeString(outBin, "%EOF%"); // free resources outBin.flush(); // stopping? if (cancelling) { cancelConnexion(); return; } initBigPipe(); MagicUIComponents.magicForm.initGame(); } } catch (Throwable e) { NetworkActor.cancelling = true; LoaderConsole.endTask(); cancelConnexion(); JOptionPane.showMessageDialog(MagicUIComponents.magicForm, LanguageManager.getString("wiz_server.error") + " : " + e.getMessage(), LanguageManager.getString("error"), JOptionPane.WARNING_MESSAGE); Log.error(e); return; } }