List of usage examples for javax.swing JOptionPane showConfirmDialog
public static int showConfirmDialog(Component parentComponent, Object message, String title, int optionType) throws HeadlessException
optionType
parameter. From source file:edu.ku.brc.specify.toycode.UpdatesApp.java
/** * @param upDesc// w w w . jav a 2s. com * @param ver * @param vs1 * @param vs2 */ protected void setAsUpdate(final UpdateDescriptor upDesc, final String ver, final String vs1, final String vs2) { int i2 = (Integer.parseInt(vs2) - 1); if (i2 < 0) { i2 += 100; } String newVersion = ver + "." + vs1 + "." + vs2; String verMin = ver + "." + vs1 + "." + i2; try { for (UpdateEntry entry : upDesc.getEntries()) { if (!entry.getNewVersion().equals(newVersion)) { String msg = String.format( "The Update entry '%s'\n has the wrong version number '%s'\nThe version should be '%s'!", entry.getFileName(), entry.getNewVersion(), newVersion); if (doingCmdLine) { System.err.println(msg); } else { JOptionPane.showConfirmDialog(null, msg, "Version Mismatch", JOptionPane.ERROR_MESSAGE); } } entry.setUpdatableVersionMax(verMin); entry.setUpdatableVersionMin(verMin); } } catch (java.lang.NullPointerException ex) { System.err.println("****UpdateDescriptor has no entries."); } }
From source file:de.freese.base.swing.mac_os_x.MyApp.java
/** * General quit handler; fed to the OSXAdapter as the method to call when a * system quit event<br>/*from ww w . j a v a 2 s . com*/ * occurs. A quit event is triggered by Cmd-Q, selecting Quit from the * application or<br> * Dock menu, or logging out. * <p/> * @return boolean */ public boolean quit() { int option = JOptionPane.showConfirmDialog(this, "Are you sure you want to quit?", "Quit?", JOptionPane.YES_NO_OPTION); return (option == JOptionPane.YES_OPTION); }
From source file:net.sf.profiler4j.console.ClassListPanel.java
/** * This method initializes addAsRuleButton * //w ww. j a v a2 s . c o m * @return javax.swing.JButton */ private JButton getAddAsRuleButton() { if (addAsRuleButton == null) { addAsRuleButton = new JButton(); addAsRuleButton .setIcon(new ImageIcon(getClass().getResource("/net/sf/profiler4j/console/images/wand.png"))); addAsRuleButton.setToolTipText("Create rules from classes"); addAsRuleButton.setEnabled(false); addAsRuleButton.setPreferredSize(new java.awt.Dimension(28, 28)); addAsRuleButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent e) { int ret = JOptionPane.showConfirmDialog(ClassListPanel.this, "Create rules from selected classes?", "Question", JOptionPane.YES_NO_OPTION); if (ret == JOptionPane.OK_OPTION) { int i = 0; for (int r : classesTable.getSelectedRows()) { String n = (String) classListTableModel.getRow(r).info.getName(); Rule rule = new Rule(n + ".*(*)", Rule.Action.ACCEPT); app.getProject().getRules().add(i++, rule); } ProjectDialog d = new ProjectDialog(app.getMainFrame(), app); d.edit(app.getProject()); } } }); } return addAsRuleButton; }
From source file:com.intuit.tank.proxy.ProxyApp.java
private JPanel getTransactionTable() { JPanel frame = new JPanel(new BorderLayout()); model = new TransactionTableModel(); final JTable table = new TransactionTable(model); final TableRowSorter<TableModel> sorter = new TableRowSorter<TableModel>(model); table.setRowSorter(sorter);/*from w ww . j a va 2 s .co m*/ final JPopupMenu pm = new JPopupMenu(); JMenuItem item = new JMenuItem("Delete Selected"); item.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { int[] selectedRows = table.getSelectedRows(); if (selectedRows.length != 0) { int response = JOptionPane.showConfirmDialog(ProxyApp.this, "Are you sure you want to delete " + selectedRows.length + " Transactions?", "Confirm Delete", JOptionPane.YES_NO_OPTION); if (response == JOptionPane.YES_OPTION) { int[] correctedRows = new int[selectedRows.length]; for (int i = selectedRows.length; --i >= 0;) { int row = selectedRows[i]; int index = (Integer) table.getValueAt(row, 0) - 1; correctedRows[i] = index; } Arrays.sort(correctedRows); for (int i = correctedRows.length; --i >= 0;) { int row = correctedRows[i]; Transaction transaction = model.getTransactionForIndex(row); if (transaction != null) { model.removeTransaction(transaction, row); isDirty = true; saveAction.setEnabled(isDirty && !stopAction.isEnabled()); } } } } } }); pm.add(item); table.add(pm); table.addMouseListener(new MouseAdapter() { boolean pressed = false; public void mouseClicked(MouseEvent e) { if (e.getClickCount() == 2) { Point p = e.getPoint(); int row = table.rowAtPoint(p); int index = (Integer) table.getValueAt(row, 0) - 1; Transaction transaction = model.getTransactionForIndex(index); if (transaction != null) { detailsTF.setText(transaction.toString()); detailsTF.setCaretPosition(0); detailsDialog.setVisible(true); } } } /** * @{inheritDoc */ @Override public void mousePressed(MouseEvent e) { if (e.isPopupTrigger()) { pressed = true; int[] selectedRows = table.getSelectedRows(); if (selectedRows.length != 0) { pm.show(e.getComponent(), e.getX(), e.getY()); } } } /** * @{inheritDoc */ @Override public void mouseReleased(MouseEvent e) { if (!pressed && e.isPopupTrigger()) { int[] selectedRows = table.getSelectedRows(); if (selectedRows.length != 0) { pm.show(e.getComponent(), e.getX(), e.getY()); } } } }); JScrollPane pane = new JScrollPane(table); frame.add(pane, BorderLayout.CENTER); JPanel panel = new JPanel(new BorderLayout()); JLabel label = new JLabel("Filter: "); panel.add(label, BorderLayout.WEST); final JLabel countLabel = new JLabel(" Count: 0 "); panel.add(countLabel, BorderLayout.EAST); final JTextField filterText = new JTextField(""); filterText.addKeyListener(new KeyAdapter() { public void keyTyped(KeyEvent e) { String text = filterText.getText(); if (text.length() == 0) { sorter.setRowFilter(null); } else { try { sorter.setRowFilter(RowFilter.regexFilter(text)); countLabel.setText(" Count: " + sorter.getViewRowCount() + " "); } catch (PatternSyntaxException pse) { System.err.println("Bad regex pattern"); } } } }); panel.add(filterText, BorderLayout.CENTER); frame.add(panel, BorderLayout.NORTH); return frame; }
From source file:edu.virginia.speclab.juxta.author.view.export.WebServiceExportDialog.java
private void onExportClicked() { File jxt = null;//from w ww. ja v a2 s . c o m boolean errorHandled = false; try { // make sure all data has been specified String setName = this.nameEdit.getText(); if (setName.length() == 0) { JOptionPane.showMessageDialog(this.juxtaFrame, "Please enter an export name for this session", "Missing Data", JOptionPane.ERROR_MESSAGE); return; } // dump the session to a temporary jxt file // and send this to the web service. Note that the // false param on the save marks this as a temporary one // that does not alter the session itself jxt = File.createTempFile("export", ".jxt"); this.juxtaFrame.getSession().saveSessionForExport(jxt); final String desc = this.descriptionEdit.getText(); try { // do the export showStatusUI(); authenticateUser(); this.exportTaskId = this.wsClient.beginExport(jxt, setName, desc); } catch (Exception e) { // catch naming conflict errors and prompt to overwrite if (e.getMessage().contains("Conflict")) { int resp = JOptionPane.showConfirmDialog(this.juxtaFrame, "A comparison set with this name already exists. Overwrite it?", "Overwrite", JOptionPane.YES_NO_OPTION); if (resp == JOptionPane.YES_OPTION) { this.statusLabel.setText("Re-Exporting JXT"); this.exportTaskId = this.wsClient.beginExport(jxt, setName, desc, true); } else { errorHandled = true; showSetupUI(); return; } } else { RequestStatus status = new RequestStatus(Status.FAILED, e.getMessage()); displayStatus(status); return; } } // kick off a thread that will do the // status check requests. this.statusTask = this.scheduler.scheduleAtFixedRate(new Runnable() { public void run() { final WebServiceClient client = WebServiceExportDialog.this.wsClient; final String id = WebServiceExportDialog.this.exportTaskId; try { RequestStatus status = client.getExportStatus(id); displayStatus(status); if (status.isTerminated()) { WebServiceExportDialog.this.statusTask.cancel(false); } } catch (IOException e) { RequestStatus status = new RequestStatus(Status.FAILED, e.getMessage()); displayStatus(status); WebServiceExportDialog.this.statusTask.cancel(false); } } }, 2, 2, TimeUnit.SECONDS); } catch (Exception e) { if (errorHandled == false) { JOptionPane.showMessageDialog(this.juxtaFrame, "Unable to export session:\n " + e.getMessage(), "Failure", JOptionPane.ERROR_MESSAGE); showSetupUI(); } } finally { if (jxt != null) { jxt.delete(); } } }
From source file:net.sf.jabref.exporter.SaveDatabaseAction.java
/** * Run the "Save as" operation. This method offloads the actual save operation to a background thread, but * still runs synchronously using Spin (the method returns only after completing the operation). *///from www. ja v a 2s . co m public void saveAs() throws Throwable { String chosenFile; File f = null; while (f == null) { chosenFile = FileDialogs.getNewFile(frame, new File(Globals.prefs.get(JabRefPreferences.WORKING_DIRECTORY)), ".bib", JFileChooser.SAVE_DIALOG, false, null); if (chosenFile == null) { canceled = true; return; // canceled } f = new File(chosenFile); // Check if the file already exists: if (f.exists() && (JOptionPane.showConfirmDialog(frame, Localization.lang("'%0' exists. Overwrite file?", f.getName()), Localization.lang("Save database"), JOptionPane.OK_CANCEL_OPTION) != JOptionPane.OK_OPTION)) { f = null; } } if (f != null) { File oldFile = panel.getBibDatabaseContext().getDatabaseFile(); panel.getBibDatabaseContext().setDatabaseFile(f); Globals.prefs.put(JabRefPreferences.WORKING_DIRECTORY, f.getParent()); runCommand(); // If the operation failed, revert the file field and return: if (!success) { panel.getBibDatabaseContext().setDatabaseFile(oldFile); return; } // Register so we get notifications about outside changes to the file. try { panel.setFileMonitorHandle(Globals.fileUpdateMonitor.addUpdateListener(panel, panel.getBibDatabaseContext().getDatabaseFile())); } catch (IOException ex) { LOGGER.error("Problem registering file change notifications", ex); } frame.getFileHistory().newFile(panel.getBibDatabaseContext().getDatabaseFile().getPath()); } frame.updateEnabledState(); }
From source file:com.sec.ose.osi.ui.frm.main.JMenuMain.java
private JMenuItem getJMenuItemSyncToServer() { if (jMenuItemSyncToServer == null) { jMenuItemSyncToServer = new JMenuItem(); jMenuItemSyncToServer.setText("Sync to Server (flush identify queue)"); jMenuItemSyncToServer.setEnabled(true); jMenuItemSyncToServer.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent e) { log.debug("Sync to Server clicked"); String title = "Sync to server - " + IdentifyMediator.getInstance().getSelectedProjectName(); String message = "OSI will flush all items in identify queue without UI update.\n" + "You are strongly suggested to click \"Sync From Server\" after completing this task.\n" + "Do you want to progress it now?"; int yesNo = JOptionPane.showConfirmDialog(null, message, title, JOptionPane.YES_NO_OPTION); if (yesNo == JOptionPane.NO_OPTION) return; mEventHandler.handle(EventHandler.MAN_TOOL_SYNC_TO_SERVER); }/*from w ww. j a v a 2s . c o m*/ }); } return jMenuItemSyncToServer; }
From source file:com.nbt.TreeFrame.java
private void createActions() { newAction = new NBTAction("New", "New", "New", KeyEvent.VK_N) { {// ww w . j av a2 s . c om putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke('N', Event.CTRL_MASK)); } @Override public void actionPerformed(ActionEvent e) { updateTreeTable(new CompoundTag("")); } }; browseAction = new NBTAction("Browse...", "Open", "Browse...", KeyEvent.VK_O) { { putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke('O', Event.CTRL_MASK)); } @Override public void actionPerformed(ActionEvent e) { JFileChooser fc = createFileChooser(); switch (fc.showOpenDialog(TreeFrame.this)) { case JFileChooser.APPROVE_OPTION: File file = fc.getSelectedFile(); Preferences prefs = getPreferences(); prefs.put(KEY_FILE, file.getAbsolutePath()); doImport(file); break; } } }; saveAction = new NBTAction("Save", "Save", "Save", KeyEvent.VK_S) { { putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke('S', Event.CTRL_MASK)); } @Override public void actionPerformed(ActionEvent e) { String path = textFile.getText(); File file = new File(path); if (file.canWrite()) { doExport(file); } else { saveAsAction.actionPerformed(e); } } }; saveAsAction = new NBTAction("Save As...", "SaveAs", "Save As...", KeyEvent.VK_UNDEFINED) { public void actionPerformed(ActionEvent e) { JFileChooser fc = createFileChooser(); switch (fc.showSaveDialog(TreeFrame.this)) { case JFileChooser.APPROVE_OPTION: File file = fc.getSelectedFile(); Preferences prefs = getPreferences(); prefs.put(KEY_FILE, file.getAbsolutePath()); doExport(file); break; } } }; refreshAction = new NBTAction("Refresh", "Refresh", "Refresh", KeyEvent.VK_F5) { { putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke("F5")); } public void actionPerformed(ActionEvent e) { String path = textFile.getText(); File file = new File(path); if (file.canRead()) doImport(file); else showErrorDialog("The file could not be read."); } }; exitAction = new NBTAction("Exit", "Exit", KeyEvent.VK_ESCAPE) { @Override public void actionPerformed(ActionEvent e) { // TODO: this should check to see if any changes have been made // before exiting System.exit(0); } }; cutAction = new DefaultEditorKit.CutAction() { { String name = "Cut"; putValue(NAME, name); putValue(SHORT_DESCRIPTION, name); putValue(MNEMONIC_KEY, KeyEvent.VK_X); putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke('X', Event.CTRL_MASK)); ImageFactory factory = new ImageFactory(); try { putValue(SMALL_ICON, new ImageIcon(factory.readGeneralImage(name, NBTAction.smallIconSize))); } catch (IOException e) { e.printStackTrace(); } try { putValue(LARGE_ICON_KEY, new ImageIcon(factory.readGeneralImage(name, NBTAction.largeIconSize))); } catch (IOException e) { e.printStackTrace(); } } }; copyAction = new DefaultEditorKit.CopyAction() { { String name = "Copy"; putValue(NAME, name); putValue(SHORT_DESCRIPTION, name); putValue(MNEMONIC_KEY, KeyEvent.VK_C); putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke('C', Event.CTRL_MASK)); ImageFactory factory = new ImageFactory(); try { putValue(SMALL_ICON, new ImageIcon(factory.readGeneralImage(name, NBTAction.smallIconSize))); } catch (IOException e) { e.printStackTrace(); } try { putValue(LARGE_ICON_KEY, new ImageIcon(factory.readGeneralImage(name, NBTAction.largeIconSize))); } catch (IOException e) { e.printStackTrace(); } } }; pasteAction = new DefaultEditorKit.CutAction() { { String name = "Paste"; putValue(NAME, name); putValue(SHORT_DESCRIPTION, name); putValue(MNEMONIC_KEY, KeyEvent.VK_V); putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke('V', Event.CTRL_MASK)); ImageFactory factory = new ImageFactory(); try { putValue(SMALL_ICON, new ImageIcon(factory.readGeneralImage(name, NBTAction.smallIconSize))); } catch (IOException e) { e.printStackTrace(); } try { putValue(LARGE_ICON_KEY, new ImageIcon(factory.readGeneralImage(name, NBTAction.largeIconSize))); } catch (IOException e) { e.printStackTrace(); } } }; deleteAction = new NBTAction("Delete", "Delete", "Delete", KeyEvent.VK_DELETE) { { putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke("DELETE")); } public void actionPerformed(ActionEvent e) { int row = treeTable.getSelectedRow(); TreePath path = treeTable.getPathForRow(row); Object last = path.getLastPathComponent(); if (last instanceof NBTFileBranch) { NBTFileBranch branch = (NBTFileBranch) last; File file = branch.getFile(); String name = file.getName(); String message = "Are you sure you want to delete " + name + "?"; String title = "Continue?"; int option = JOptionPane.showConfirmDialog(TreeFrame.this, message, title, JOptionPane.OK_CANCEL_OPTION); switch (option) { case JOptionPane.CANCEL_OPTION: return; } if (!FileUtils.deleteQuietly(file)) { showErrorDialog(name + " could not be deleted."); return; } } TreePath parentPath = path.getParentPath(); Object parentLast = parentPath.getLastPathComponent(); NBTTreeTableModel model = treeTable.getTreeTableModel(); int index = model.getIndexOfChild(parentLast, last); if (parentLast instanceof Mutable<?>) { Mutable<?> mutable = (Mutable<?>) parentLast; if (last instanceof ByteWrapper) { ByteWrapper wrapper = (ByteWrapper) last; index = wrapper.getIndex(); } mutable.remove(index); } else { System.err.println(last.getClass()); return; } updateTreeTable(); treeTable.expandPath(parentPath); scrollTo(parentLast); treeTable.setRowSelectionInterval(row, row); } }; openAction = new NBTAction("Open...", "Open...", KeyEvent.VK_T) { { putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke('T', Event.CTRL_MASK)); final int diamondPickaxe = 278; SpriteRecord record = NBTTreeTable.register.getRecord(diamondPickaxe); BufferedImage image = record.getImage(); setSmallIcon(image); int width = 24, height = 24; Dimension size = new Dimension(width, height); Map<RenderingHints.Key, ?> hints = Thumbnail.createRenderingHints(Thumbnail.QUALITY); BufferedImage largeImage = Thumbnail.createThumbnail(image, size, hints); setLargeIcon(largeImage); } public void actionPerformed(ActionEvent e) { TreePath path = treeTable.getPath(); if (path == null) return; Object last = path.getLastPathComponent(); if (last instanceof Region) { Region region = (Region) last; createAndShowTileCanvas(new TileCanvas.TileWorld(region)); return; } else if (last instanceof World) { World world = (World) last; createAndShowTileCanvas(world); return; } if (last instanceof NBTFileBranch) { NBTFileBranch fileBranch = (NBTFileBranch) last; File file = fileBranch.getFile(); try { open(file); } catch (IOException ex) { ex.printStackTrace(); showErrorDialog(ex.getMessage()); } } } private void open(File file) throws IOException { if (Desktop.isDesktopSupported()) { Desktop desktop = Desktop.getDesktop(); if (desktop.isSupported(Desktop.Action.OPEN)) { desktop.open(file); } } } }; addByteAction = new NBTAction("Add Byte", NBTConstants.TYPE_BYTE, "Add Byte", KeyEvent.VK_1) { { putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke('1', Event.CTRL_MASK)); } public void actionPerformed(ActionEvent e) { addTag(new ByteTag("new byte", (byte) 0)); } }; addShortAction = new NBTAction("Add Short", NBTConstants.TYPE_SHORT, "Add Short", KeyEvent.VK_2) { { putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke('2', Event.CTRL_MASK)); } public void actionPerformed(ActionEvent e) { addTag(new ShortTag("new short", (short) 0)); } }; addIntAction = new NBTAction("Add Integer", NBTConstants.TYPE_INT, "Add Integer", KeyEvent.VK_3) { { putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke('3', Event.CTRL_MASK)); } public void actionPerformed(ActionEvent e) { addTag(new IntTag("new int", 0)); } }; addLongAction = new NBTAction("Add Long", NBTConstants.TYPE_LONG, "Add Long", KeyEvent.VK_4) { { putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke('4', Event.CTRL_MASK)); } public void actionPerformed(ActionEvent e) { addTag(new LongTag("new long", 0)); } }; addFloatAction = new NBTAction("Add Float", NBTConstants.TYPE_FLOAT, "Add Float", KeyEvent.VK_5) { { putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke('5', Event.CTRL_MASK)); } public void actionPerformed(ActionEvent e) { addTag(new FloatTag("new float", 0)); } }; addDoubleAction = new NBTAction("Add Double", NBTConstants.TYPE_DOUBLE, "Add Double", KeyEvent.VK_6) { { putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke('6', Event.CTRL_MASK)); } public void actionPerformed(ActionEvent e) { addTag(new DoubleTag("new double", 0)); } }; addByteArrayAction = new NBTAction("Add Byte Array", NBTConstants.TYPE_BYTE_ARRAY, "Add Byte Array", KeyEvent.VK_7) { { putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke('7', Event.CTRL_MASK)); } public void actionPerformed(ActionEvent e) { addTag(new ByteArrayTag("new byte array")); } }; addStringAction = new NBTAction("Add String", NBTConstants.TYPE_STRING, "Add String", KeyEvent.VK_8) { { putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke('8', Event.CTRL_MASK)); } public void actionPerformed(ActionEvent e) { addTag(new StringTag("new string", "...")); } }; addListAction = new NBTAction("Add List Tag", NBTConstants.TYPE_LIST, "Add List Tag", KeyEvent.VK_9) { { putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke('9', Event.CTRL_MASK)); } public void actionPerformed(ActionEvent e) { Class<? extends Tag> type = queryType(); if (type != null) addTag(new ListTag("new list", null, type)); } private Class<? extends Tag> queryType() { Object[] items = { NBTConstants.TYPE_BYTE, NBTConstants.TYPE_SHORT, NBTConstants.TYPE_INT, NBTConstants.TYPE_LONG, NBTConstants.TYPE_FLOAT, NBTConstants.TYPE_DOUBLE, NBTConstants.TYPE_BYTE_ARRAY, NBTConstants.TYPE_STRING, NBTConstants.TYPE_LIST, NBTConstants.TYPE_COMPOUND }; JComboBox comboBox = new JComboBox(new DefaultComboBoxModel(items)); comboBox.setRenderer(new DefaultListCellRenderer() { @Override public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); if (value instanceof Integer) { Integer i = (Integer) value; Class<? extends Tag> c = NBTUtils.getTypeClass(i); String name = NBTUtils.getTypeName(c); setText(name); } return this; } }); Object[] message = { new JLabel("Please select a type."), comboBox }; String title = "Title goes here"; int result = JOptionPane.showOptionDialog(TreeFrame.this, message, title, JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, null, null, null); switch (result) { case JOptionPane.OK_OPTION: ComboBoxModel model = comboBox.getModel(); Object item = model.getSelectedItem(); if (item instanceof Integer) { Integer i = (Integer) item; return NBTUtils.getTypeClass(i); } } return null; } }; addCompoundAction = new NBTAction("Add Compound Tag", NBTConstants.TYPE_COMPOUND, "Add Compound Tag", KeyEvent.VK_0) { { putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke('0', Event.CTRL_MASK)); } public void actionPerformed(ActionEvent e) { addTag(new CompoundTag()); } }; String name = "About " + TITLE; helpAction = new NBTAction(name, "Help", name, KeyEvent.VK_F1) { { putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke("F1")); } public void actionPerformed(ActionEvent e) { Object[] message = { new JLabel(TITLE + " " + VERSION), new JLabel("\u00A9 Copyright Taggart Spilman 2011. All rights reserved."), new Hyperlink("<html><a href=\"#\">NamedBinaryTag.com</a></html>", "http://www.namedbinarytag.com"), new Hyperlink("<html><a href=\"#\">Contact</a></html>", "mailto:tagadvance@gmail.com"), new JLabel(" "), new Hyperlink("<html><a href=\"#\">JNBT was written by Graham Edgecombe</a></html>", "http://jnbt.sf.net"), new Hyperlink("<html><a href=\"#\">Available open-source under the BSD license</a></html>", "http://jnbt.sourceforge.net/LICENSE.TXT"), new JLabel(" "), new JLabel("This product includes software developed by"), new Hyperlink("<html><a href=\"#\">The Apache Software Foundation</a>.</html>", "http://www.apache.org"), new JLabel(" "), new JLabel("Default texture pack:"), new Hyperlink("<html><a href=\"#\">SOLID COLOUR. SOLID STYLE.</a></html>", "http://www.minecraftforum.net/topic/72253-solid-colour-solid-style/"), new JLabel("Bundled with the permission of Trigger_Proximity."), }; String title = "About"; JOptionPane.showMessageDialog(TreeFrame.this, message, title, JOptionPane.INFORMATION_MESSAGE); } }; }
From source file:com.igormaznitsa.jhexed.swing.editor.ui.dialogs.hexeditors.DialogEditSVGImageValue.java
private void buttonSaveAsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonSaveAsActionPerformed final JFileChooser dlg = new JFileChooser(); dlg.addChoosableFileFilter(new FileFilter() { @Override/* w w w . ja v a2s. c o m*/ public boolean accept(File f) { return f.isDirectory() || f.getName().toLowerCase(Locale.ENGLISH).endsWith(".svg"); } @Override public String getDescription() { return "SVG files (*.svg)"; } }); if (dlg.showSaveDialog(this) == JFileChooser.APPROVE_OPTION) { File file = dlg.getSelectedFile(); if (FilenameUtils.getExtension(file.getName()).isEmpty()) { file = new File(file.getParentFile(), file.getName() + ".svg"); } if (file.exists() && JOptionPane.showConfirmDialog(this.parent, "Overwrite file '" + file.getAbsolutePath() + "\'?", "Overwriting", JOptionPane.OK_CANCEL_OPTION) == JOptionPane.CANCEL_OPTION) { return; } try { FileUtils.writeByteArrayToFile(file, this.value.getImage().getImageData()); } catch (IOException ex) { Log.error("Can't write image [" + file + ']', ex); JOptionPane.showMessageDialog(this, "Can't save the file for error!", "IO Error", JOptionPane.ERROR_MESSAGE); } } }
From source file:net.landora.video.manager.ManagerFrame.java
public void exit() { int reply = JOptionPane.showConfirmDialog(this, "Are you sure you wish to quit?", "Exit", JOptionPane.YES_NO_OPTION); if (reply == JOptionPane.YES_OPTION) { System.exit(0);//from w w w. ja va 2 s. co m } }