List of usage examples for javax.swing JOptionPane YES_OPTION
int YES_OPTION
To view the source code for javax.swing JOptionPane YES_OPTION.
Click Source Link
From source file:net.minder.KnoxWebHdfsJavaClientExamplesTest.java
@BeforeClass public static void setupSuite() { Console console = System.console(); if (console != null) { console.printf("Knox Host: "); KNOX_HOST = console.readLine();//from w w w . j av a 2 s .c o m console.printf("Topology : "); TOPOLOGY_PATH = console.readLine(); console.printf("Username : "); TEST_USERNAME = console.readLine(); console.printf("Password: "); TEST_PASSWORD = new String(console.readPassword()); } else { JLabel label = new JLabel("Enter Knox host, topology, username, password:"); JTextField host = new JTextField(KNOX_HOST); JTextField topology = new JTextField(TOPOLOGY_PATH); JTextField username = new JTextField(TEST_USERNAME); JPasswordField password = new JPasswordField(TEST_PASSWORD); int choice = JOptionPane.showConfirmDialog(null, new Object[] { label, host, topology, username, password }, "Credentials", JOptionPane.OK_CANCEL_OPTION); assertThat(choice, is(JOptionPane.YES_OPTION)); TEST_USERNAME = username.getText(); TEST_PASSWORD = new String(password.getPassword()); KNOX_HOST = host.getText(); TOPOLOGY_PATH = topology.getText(); } TOPOLOGY_URL = String.format("%s://%s:%d/%s/%s", KNOX_SCHEME, KNOX_HOST, KNOX_PORT, KNOX_PATH, TOPOLOGY_PATH); WEBHDFS_URL = String.format("%s/%s", TOPOLOGY_URL, WEBHDFS_PATH); }
From source file:ca.sqlpower.wabit.swingui.action.DeleteWabitServerWorkspaceAction.java
public void actionPerformed(ActionEvent e) { try {/*from w ww . ja v a2s. c o m*/ WabitSwingSessionImpl activeSwingSession = (WabitSwingSessionImpl) context.getActiveSwingSession(); if (activeSwingSession == null) { JOptionPane.showMessageDialog(context.getFrame(), "That button refreshes the current workspace,\n" + "but there is no workspace selected right now."); return; } int choice = JOptionPane.showConfirmDialog(context.getFrame(), "By deleting this workspace, " + "you will not be able to recover any of its contents.\n" + "Are you sure you want to delete it?", "Are you sure?", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE); if (choice == JOptionPane.YES_OPTION) { activeSwingSession.delete(); } } catch (ClientProtocolException ex) { throw new RuntimeException(ex); } catch (URISyntaxException ex) { throw new RuntimeException(ex); } catch (IOException ex) { throw new RuntimeException(ex); } }
From source file:org.keyboardplaying.xtt.ui.action.ConfirmClearPrefsAction.java
@Override public void perform() throws ActionException { int confirm = JOptionPane.showConfirmDialog(null, i18nHelper.getMessage("warning.prefs.clear.close"), "Are you sure?", JOptionPane.YES_NO_OPTION); if (confirm == JOptionPane.YES_OPTION) { clearPrefsAction.perform();// w w w . j av a 2 s . c o m disposeAllWindows(); } }
From source file:net.sf.housekeeper.HousekeeperLifecycleAdvisor.java
/** * Ask if user wants to save before exiting. *//*from ww w .ja va 2 s . c o m*/ public boolean onPreWindowClose(ApplicationWindow window) { boolean exit = true; final ActionCommand saveCommand = window.getCommandManager().getActionCommand("saveCommand"); // Only show dialog for saving before exiting if any data has been // changed if (saveCommand.isEnabled()) { final String question = getApplicationServices().getMessages() .getMessage("gui.mainFrame.saveModificationsQuestion"); final int option = JOptionPane.showConfirmDialog(window.getControl(), question); // If user choses yes try to save. If that fails do not exit. if (option == JOptionPane.YES_OPTION) { saveCommand.execute(); } else if (option == JOptionPane.CANCEL_OPTION) { exit = false; } } return exit; }
From source file:calendarexportplugin.exporter.CalExporter.java
public boolean exportPrograms(Program[] programs, CalendarExportSettings settings, AbstractPluginProgramFormating formatting) { mSavePath = getSavePath(settings);/* ww w .ja va 2 s . c o m*/ File file = chooseFile(programs); if (file == null) { return false; } if (file.exists()) { int result = JOptionPane.showConfirmDialog(CalendarExportPlugin.getInstance().getBestParentFrame(), mLocalizer.msg("overwriteMessage", "The File \n{0}\nalready exists. Overwrite it?", file.getAbsolutePath()), mLocalizer.msg("overwriteTitle", "Overwrite?"), JOptionPane.YES_NO_OPTION); if (result != JOptionPane.YES_OPTION) { return false; } } mSavePath = file.getAbsolutePath(); setSavePath(settings, mSavePath); export(file, programs, settings, formatting); return true; }
From source file:net.menthor.editor.v2.util.Util.java
public static JFileChooser createChooser(String lastPath, final boolean checkOverrideFile) { return new JFileChooser(lastPath) { private static final long serialVersionUID = 1L; @Override// www . java 2 s.c o m public void approveSelection() { File f = getSelectedFile(); if (f.exists() && checkOverrideFile) { int result = JOptionPane.showConfirmDialog(this, "\"" + f.getName() + "\" already exists. Do you want to overwrite it?", "Existing file", JOptionPane.YES_NO_CANCEL_OPTION); switch (result) { case JOptionPane.YES_OPTION: super.approveSelection(); return; case JOptionPane.NO_OPTION: return; case JOptionPane.CLOSED_OPTION: return; case JOptionPane.CANCEL_OPTION: cancelSelection(); return; } } super.approveSelection(); } }; }
From source file:com.BuildCraft.install.InstallMain.java
public void confirmInstall() { boolean fileNotInstalled = false; for (int i = 0; i < fileList.length; i++) { if (!fileList[i].exists()) { fileNotInstalled = true;//w ww . ja v a 2 s . c o m break; } } if (fileNotInstalled) { int option = JOptionPane.showConfirmDialog(null, "Part or All of BuildCraft is not installed!\nInstall?"); if (option == JOptionPane.YES_OPTION) { ConsoleOut.printMsg("Installing BuildCraft..."); doInstall(); } else { ConsoleOut.printMsg("BuildCraft Installation Canceled"); BuildCraft.cleanExit(BCExitState.NORMAL); } } }
From source file:gui.FormFrame.java
FormFrame(MainHandler mainHandler, final String usage, Pays argpays) throws PaysNotFoundException { this.setResizable(false); this.usage = usage; this.argpays = argpays; mainPanel = new JPanel(); formPanel = new JPanel(); this.mainHandler = mainHandler; //this.setLayout(new FlowLayout()); this.getContentPane().add(mainPanel); init();//from w w w .ja va 2s . co m this.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); this.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { close(); } public void close() { int dialButton = JOptionPane.OK_CANCEL_OPTION; int dialResult; dialResult = JOptionPane.showConfirmDialog(null, "Vous etes sur le point de quitter sans avoir" + usage, "Attention !", dialButton); if (dialResult == JOptionPane.YES_OPTION) { dispose(); } } }); }
From source file:ca.uviccscu.lp.utils.Utils.java
@Deprecated public static boolean checkDir(File f) { l.trace("Checking dir: " + f.getAbsolutePath()); try {/*from w w w . j av a 2 s. c o m*/ boolean a = f.isDirectory(); if (a) { if (f.listFiles().length != 0) { l.error("Directory not empty"); //JDialog jd = new JDialog((JFrame) null, true); int resp = JOptionPane.showConfirmDialog(null, "Directory nonempty: " + f.getAbsolutePath() + ". Proceed? (will wipe)", "Confirm deletion", JOptionPane.YES_NO_OPTION); if (resp == JOptionPane.YES_OPTION) { FileUtils.deleteDirectory(f); } else { l.fatal("Delete denied"); System.exit(1); } } } FileUtils.forceMkdir(f); File test = new File(f.getAbsolutePath() + File.separator + "test.file"); boolean c = test.createNewFile(); return c; } catch (Exception e) { l.fatal("Az directory creation error", e); return false; } }
From source file:net.sf.taverna.t2.renderers.SVGRenderer.java
@SuppressWarnings("serial") public JComponent getComponent(Path path) throws RendererException { if (DataBundles.isValue(path) || DataBundles.isReference(path)) { long approximateSizeInBytes = 0; try {/*from ww w . j ava2s . c om*/ approximateSizeInBytes = RendererUtils.getSizeInBytes(path); } catch (Exception ex) { logger.error("Failed to get the size of the data", ex); return new JTextArea("Failed to get the size of the data (see error log for more details): \n" + ex.getMessage()); } if (approximateSizeInBytes > MEGABYTE) { int response = JOptionPane.showConfirmDialog(null, "Result is approximately " + bytesToMeg(approximateSizeInBytes) + " MB in size, there could be issues with rendering this inside Taverna\nDo you want to continue?", "Render as SVG?", JOptionPane.YES_NO_OPTION); if (response != JOptionPane.YES_OPTION) { return new JTextArea( "Rendering cancelled due to size of data. Try saving and viewing in an external application."); } } String resolve = null; try { // Resolve it as a string resolve = RendererUtils.getString(path); } catch (Exception e) { logger.error("Reference Service failed to render data as string", e); return new JTextArea( "Reference Service failed to render data as string (see error log for more details): \n" + e.getMessage()); } final JSVGCanvas svgCanvas = new JSVGCanvas(); File tmpFile = null; try { tmpFile = File.createTempFile("taverna", "svg"); tmpFile.deleteOnExit(); FileUtils.writeStringToFile(tmpFile, resolve, "utf8"); } catch (IOException e) { logger.error("SVG Renderer: Failed to write the data to temporary file", e); return new JTextArea( "Failed to write the data to temporary file (see error log for more details): \n" + e.getMessage()); } try { svgCanvas.setURI(tmpFile.toURI().toASCIIString()); } catch (Exception e) { logger.error("Failed to create SVG renderer", e); return new JTextArea( "Failed to create SVG renderer (see error log for more details): \n" + e.getMessage()); } JPanel jp = new JPanel() { @Override protected void finalize() throws Throwable { svgCanvas.stopProcessing(); super.finalize(); } }; jp.add(svgCanvas); return jp; } else { logger.error("Failed to obtain the data to render: data is not a value or reference"); return new JTextArea("Failed to obtain the data to render: data is not a value or reference"); } }