List of usage examples for javax.swing JOptionPane showMessageDialog
public static void showMessageDialog(Component parentComponent, Object message, String title, int messageType) throws HeadlessException
messageType
parameter. From source file:com.mightypocket.ashot.AShot.java
void showErrorMessage(String messageKey, Object... args) { ResourceMap resourceMap = getContext().getResourceMap(); String message = resourceMap.getString(messageKey, args); String errorTitle = resourceMap.getString("error.title"); JOptionPane.showMessageDialog(getMainFrame(), message, errorTitle, JOptionPane.ERROR_MESSAGE); }
From source file:net.sf.jabref.gui.worker.VersionWorker.java
@Override public void done() { if (this.isCancelled()) { return;/*from w w w . j a v a2 s .c o m*/ } try { Version latestVersion = this.get(); if (latestVersion == null) { String couldNotConnect = Localization.lang("Couldn't connect to the update server."); String tryLater = Localization.lang("Please try again later and/or check your network connection."); if (manualExecution) { JOptionPane.showMessageDialog(this.mainFrame, couldNotConnect + "\n" + tryLater, couldNotConnect, JOptionPane.ERROR_MESSAGE); } this.mainFrame.output(couldNotConnect + " " + tryLater); return; } // only respect the ignored version on automated version checks if (latestVersion.equals(toBeIgnored) && !manualExecution) { return; } boolean newer = latestVersion.isNewerThan(installedVersion); if (newer) { new NewVersionDialog(this.mainFrame, installedVersion, latestVersion, toBeIgnored); return; } String upToDate = Localization.lang("JabRef is up-to-date."); if (manualExecution) { JOptionPane.showMessageDialog(this.mainFrame, upToDate, upToDate, JOptionPane.INFORMATION_MESSAGE); } this.mainFrame.output(upToDate); } catch (InterruptedException | ExecutionException e) { LOGGER.error("Error while checking for updates", e); } }
From source file:de.dakror.villagedefense.util.SaveHandler.java
public static void saveGame() { try {//from w w w. j a va 2s. com File save = new File(CFG.DIR, "saves/" + new SimpleDateFormat("'Spielstand' dd.MM.yyyy HH-mm-ss").format(new Date()) + ".save"); save.createNewFile(); JSONObject o = new JSONObject(); o.put("version", CFG.VERSION); o.put("created", Game.currentGame.worldCreated); o.put("width", Game.world.width); o.put("height", Game.world.height); o.put("tile", new BASE64Encoder().encode(Compressor.compressRow(Game.world.getData()))); o.put("resources", Game.currentGame.resources.getData()); o.put("researches", Game.currentGame.researches); o.put("wave", WaveManager.wave); o.put("time", WaveManager.nextWave); JSONArray entities = new JSONArray(); for (Entity e : Game.world.entities) { if ((e instanceof Forester) || (e instanceof Woodsman)) continue; // don't save them, because they get spawned by the house upgrades entities.put(e.getData()); } o.put("entities", entities); Compressor.compressFile(save, o.toString()); // Helper.setFileContent(new File(save.getPath() + ".debug"), o.toString()); Game.currentGame.state = 3; JOptionPane.showMessageDialog(Game.w, "Spielstand erfolgreich gespeichert.", "Speichern erfolgreich", JOptionPane.INFORMATION_MESSAGE); } catch (Exception e) { e.printStackTrace(); } }
From source file:by.dak.cutting.permision.PermissionManager.java
public void login() { JXLoginPane pane = new JXLoginPane(loginService); JXLoginPane.Status status = JXLoginPane.showLoginDialog(CuttingApp.getApplication().getMainFrame(), pane); if (status == JXLoginPane.Status.SUCCEEDED) { Runnable runnable = new Runnable() { public void run() { NewDayManager newDayManager = new NewDayManager(); Dailysheet dailysheet = newDayManager.checkDailysheet(); if (dailysheet == null) { Application.getInstance().exit(); }//w w w . j a v a2 s .c o m if (!newDayManager.checkCurrency(dailysheet)) { JOptionPane.showMessageDialog( ((SingleFrameApplication) Application.getInstance()).getMainFrame(), resourceMap.getString("permission.title.currency.empty"), resourceMap.getString("permission.message.currency.empty"), JOptionPane.ERROR_MESSAGE); CuttingApp.getApplication().exit(); } } }; SwingUtilities.invokeLater(runnable); } else { Application.getInstance().exit(); } }
From source file:LookAndFeelPrefs.java
/** * Create a menu of radio buttons listing the available Look and Feels. When * the user selects one, change the component hierarchy under frame to the new * LAF, and store the new selection as the current preference for the package * containing class c.//w ww . j ava 2 s . c om */ public static JMenu createLookAndFeelMenu(final Class prefsClass, final ActionListener listener) { // Create the menu final JMenu plafmenu = new JMenu("Look and Feel"); // Create an object used for radio button mutual exclusion ButtonGroup radiogroup = new ButtonGroup(); // Look up the available look and feels UIManager.LookAndFeelInfo[] plafs = UIManager.getInstalledLookAndFeels(); // Find out which one is currently used String currentLAFName = UIManager.getLookAndFeel().getClass().getName(); // Loop through the plafs, and add a menu item for each one for (int i = 0; i < plafs.length; i++) { String plafName = plafs[i].getName(); final String plafClassName = plafs[i].getClassName(); // Create the menu item final JMenuItem item = plafmenu.add(new JRadioButtonMenuItem(plafName)); item.setSelected(plafClassName.equals(currentLAFName)); // Tell the menu item what to do when it is selected item.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { // Set the new look and feel try { UIManager.setLookAndFeel(plafClassName); } catch (UnsupportedLookAndFeelException e) { // Sometimes a Look-and-Feel is installed but not // supported, as in the Windows LaF on Linux platforms. JOptionPane.showMessageDialog(plafmenu, "The selected Look-and-Feel is " + "not supported on this platform.", "Unsupported Look And Feel", JOptionPane.ERROR_MESSAGE); item.setEnabled(false); } catch (Exception e) { // ClassNotFound or Instantiation item.setEnabled(false); // shouldn't happen } // Make the selection persistent by storing it in prefs. Preferences p = Preferences.userNodeForPackage(prefsClass); p.put(PREF_NAME, plafClassName); // Invoke the supplied action listener so the calling // application can update its components to the new LAF // Reuse the event that was passed here. listener.actionPerformed(event); } }); // Only allow one menu item to be selected at once radiogroup.add(item); } return plafmenu; }
From source file:com.jostrobin.battleships.controller.GameController.java
@Override public void notify(Command command) { switch (command.getCommand()) { case Command.ATTACK_RESULT: if (command.getAttackResult() != AttackResult.INVALID) { gameFrame.hitCell(command);/*from ww w.j a v a 2 s.co m*/ AttackResult result = command.getAttackResult(); // if a ship has been destroyed, add it to the game field if (result == AttackResult.SHIP_DESTROYED || result == AttackResult.PLAYER_DESTROYED) { gameFrame.addShip(command.getAttackedClient(), command.getShip()); } playSound(result); checkGameUpdate(command); gameFrame.changeCurrentPlayer(command.getClientId()); } break; case Command.CLOSE_GAME: // the game has been aborted, go back to main screen JOptionPane.showMessageDialog(gameFrame, "The game has been aborted by another player.", "Error", JOptionPane.ERROR_MESSAGE); applicationController.showGameSelection(); gameFrame.reset(); gameModel.setPlayers(null); break; } }
From source file:Splash.java
public Splash(JFrame f, String progName, String fileName) { super();//from w w w. j ava 2s .com // Can't use Swing border on JWindow: not a JComponent. // setBorder(BorderFactory.createBevelBorder(BevelBorder.RAISED)); im = new ImageIcon(fileName); if (im.getImageLoadStatus() != MediaTracker.COMPLETE) JOptionPane.showMessageDialog(f, "Warning: can't load image " + fileName + "\n" + "Please be sure you have installed " + progName + " correctly", "Warning", JOptionPane.WARNING_MESSAGE); int w = im.getIconWidth(), h = im.getIconHeight(); setSize(w, h); UtilGUI.center(this); addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent e) { dispose(); } }); addKeyListener(new KeyAdapter() { public void keyTyped(KeyEvent e) { dispose(); } }); }
From source file:ScrollDemo2.java
public void init() { JRadioButton form[][] = new JRadioButton[12][5]; String counts[] = { "", "0-1", "2-5", "6-10", "11-100", "101+" }; String categories[] = { "Household", "Office", "Extended Family", "Company (US)", "Company (World)", "Team", "Will", "Birthday Card List", "High School", "Country", "Continent", "Planet" }; JPanel p = new JPanel(); p.setSize(600, 400);// ww w.j a va 2 s . c om p.setLayout(new GridLayout(13, 6, 10, 0)); for (int row = 0; row < 13; row++) { ButtonGroup bg = new ButtonGroup(); for (int col = 0; col < 6; col++) { if (row == 0) { p.add(new JLabel(counts[col])); } else { if (col == 0) { p.add(new JLabel(categories[row - 1])); } else { form[row - 1][col - 1] = new JRadioButton(); bg.add(form[row - 1][col - 1]); p.add(form[row - 1][col - 1]); } } } } scrollpane = new JScrollPane(p); // Add in some JViewports for the column and row headers JViewport jv1 = new JViewport(); jv1.setView(new JLabel(new ImageIcon("columnlabel.gif"))); scrollpane.setColumnHeader(jv1); JViewport jv2 = new JViewport(); jv2.setView(new JLabel(new ImageIcon("rowlabel.gif"))); scrollpane.setRowHeader(jv2); // And throw in an information button JButton jb1 = new JButton(new ImageIcon("question.gif")); jb1.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { JOptionPane.showMessageDialog(null, "This is an Active Corner!", "Information", JOptionPane.INFORMATION_MESSAGE); } }); scrollpane.setCorner(ScrollPaneConstants.UPPER_LEFT_CORNER, jb1); getContentPane().add(scrollpane, BorderLayout.CENTER); }
From source file:com.emr.utilities.SQLiteGetProcesses.java
@Override protected void done() { if (!"".equals(error_msg)) { JOptionPane.showMessageDialog(null, "Could not fetch saved procedures. Error details: " + error_msg, "Failed", JOptionPane.ERROR_MESSAGE); }// www . j a va2 s . c om }
From source file:JuliaSet2.java
public void print() { // Java 1.1 used java.awt.PrintJob. // In Java 1.2 we use java.awt.print.PrinterJob PrinterJob job = PrinterJob.getPrinterJob(); // Alter the default page settings to request landscape mode PageFormat page = job.defaultPage(); page.setOrientation(PageFormat.LANDSCAPE); // landscape by default // Tell the PrinterJob what Printable object we want to print. // PrintableComponent is defined as an inner class below String title = "Julia set for c={" + cx + "," + cy + "}"; Printable printable = new PrintableComponent(this, title); job.setPrintable(printable, page);/*from w w w . jav a 2s .c om*/ // Call the printDialog() method to give the user a chance to alter // the printing attributes or to cancel the printing request. if (job.printDialog()) { // If we get here, then the user did not cancel the print job // So start printing, displaying a dialog for errors. try { job.print(); } catch (PrinterException e) { JOptionPane.showMessageDialog(this, e.toString(), "PrinterException", JOptionPane.ERROR_MESSAGE); } } }