javax.swing.JOptionPane Java Examples
The following examples show how to use
javax.swing.JOptionPane.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source Project: ramus Author: Vitaliy-Yakovchuk File: DemoChecker.java License: GNU General Public License v3.0 | 6 votes |
@Override public void elementCreated(ElementEvent event) { IEngineImpl impl = (IEngineImpl) event.getEngine().getDeligate(); String prefix = impl.getPrefix(); long elementCount = getElementCount(impl, prefix); if (elementCount > 100) { framework.propertyChanged("DisableSaveActions"); } if ((elementCount == 101) && (framework.get("FilePlugin") != null)) { SwingUtilities.invokeLater(new Runnable() { @Override public void run() { JOptionPane.showMessageDialog(framework.getMainFrame(), MessageFormat.format(GlobalResourcesManager .getString("DemoVersionElementCountLimit"), 100)); } }); } }
Example #2
Source Project: djl-demo Author: aws-samples File: ViewerFrame.java License: Apache License 2.0 | 6 votes |
ViewerFrame(int width, int height) { frame = new JFrame("Demo"); imagePanel = new ImagePanel(); frame.setLayout(new BorderLayout()); frame.add(BorderLayout.CENTER, imagePanel); JOptionPane.setRootFrame(frame); Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); if (width > screenSize.width) { width = screenSize.width; } Dimension frameSize = new Dimension(width, height); frame.setSize(frameSize); frame.setLocation((screenSize.width - width) / 2, (screenSize.height - height) / 2); frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); frame.setVisible(true); }
Example #3
Source Project: WorldPainter Author: Captain-Chaos File: SimpleBrowser.java License: GNU General Public License v3.0 | 6 votes |
private void jEditorPane1HyperlinkUpdate(javax.swing.event.HyperlinkEvent evt) {//GEN-FIRST:event_jEditorPane1HyperlinkUpdate if (evt.getEventType() == EventType.ACTIVATED) { URL url = evt.getURL(); try { jEditorPane1.setPage(url); if (historyPointer == (historySize - 1)) { // At the end of the history history.add(url.toExternalForm()); historyPointer++; historySize++; } else { // Not at the end of the history; erase the tail end historyPointer++; history.set(historyPointer, url.toExternalForm()); historySize = historyPointer + 1; } backAction.setEnabled(true); forwardAction.setEnabled(false); } catch (IOException e) { JOptionPane.showMessageDialog(this, "I/O error loading page " + url, "Error Loading Page", JOptionPane.ERROR_MESSAGE); } } }
Example #4
Source Project: ChatGameFontificator Author: GlitchCog File: FontificatorProperties.java License: The Unlicense | 6 votes |
/** * Called whenever unsaved changes might be lost to let the user have the option to save them * * @param ctrlWindow * @return okayToContinue */ public boolean checkForUnsavedProps(ControlWindow ctrlWindow, Component parent) { if (hasUnsavedChanges()) { int response = JOptionPane.showConfirmDialog(parent, "Save configuration changes?", "Unsaved Changes", JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE); if (response == JOptionPane.YES_OPTION) { if (ctrlWindow.saveConfig()) { return true; } } else if (response == JOptionPane.NO_OPTION) { return true; } return false; } else { return true; } }
Example #5
Source Project: iBioSim Author: MyersResearchGroup File: LearnView.java License: Apache License 2.0 | 6 votes |
public void updateSpecies(String newLearnFile) { learnFile = newLearnFile; try { speciesList = Learn.writeBackgroundFile(learnFile, directory); } catch (XMLStreamException | IOException | BioSimException e) { JOptionPane.showMessageDialog(Gui.frame, "Unable to create background file!", "Error Writing Background", JOptionPane.ERROR_MESSAGE); speciesList = new ArrayList<String>(); } if (user.isSelected()) { auto.doClick(); user.doClick(); } else { user.doClick(); auto.doClick(); } }
Example #6
Source Project: JAVA-MVC-Swing-Monopoly Author: moonChenHaohui File: Control.java License: Apache License 2.0 | 6 votes |
/** * * * ʹ��ң�����ӿ� * * */ private void useControlDiceCard(Card card) { Object[] options = { "1��", "2��", "3��", "4��", "5��", "6��", "����ѡ��" }; int response = JOptionPane.showOptionDialog(null, "ȷ��ʹ��\"ң�����ӿ�\"ң�����ӵ���?", "��Ƭʹ�ý�.", JOptionPane.YES_OPTION, JOptionPane.PLAIN_MESSAGE, null, options, options[0]); if (response == -1 || response == 6) { return; } else { // ʹ�� this.run.setPoint(response); // �����ı���ʾ this.textTip.showTextTip(card.getOwner(), card.getOwner().getName() + " ʹ���� \"ң�����ӿ�\".", 2); // ����ȥ��Ƭ card.getOwner().getCards().remove(card); } }
Example #7
Source Project: BotLibre Author: BotLibre File: BotFrame.java License: Eclipse Public License 1.0 | 6 votes |
public void actionPerformed(ActionEvent event) { String database = (String)JOptionPane.showInputDialog( BotFrame.this, "Enter database name to import:", "Import Dialog", JOptionPane.PLAIN_MESSAGE, null, null, ""); if (database == null) { return; } try { getBot().memory().importMemory(database); } catch (Exception failed) { failed.printStackTrace(); JOptionPane.showMessageDialog(BotFrame.this, failed.toString(), "Import failed", JOptionPane.ERROR_MESSAGE); } }
Example #8
Source Project: pcgen Author: PCGen File: PCGenFrame.java License: GNU Lesser General Public License v2.1 | 6 votes |
/** * Revert the character to the previous save. If no previous save, open a * new character tab. * @param character The character being saved. */ public void revertCharacter(CharacterFacade character) { if (character.isDirty()) { int ret = JOptionPane.showConfirmDialog(this, LanguageBundle.getFormattedString("in_revertPcChoice", character //$NON-NLS-1$ .getNameRef().get()), Constants.APPLICATION_NAME, JOptionPane.YES_NO_OPTION); if (ret == JOptionPane.YES_OPTION) { CharacterManager.removeCharacter(character); if (character.getFileRef().get() != null && character.getFileRef().get().exists()) { openCharacter(character.getFileRef().get(), currentDataSetRef.get()); } else { createNewCharacter(null); } } } }
Example #9
Source Project: ramus Author: Vitaliy-Yakovchuk File: ReadedModel.java License: GNU General Public License v3.0 | 6 votes |
/** * @see javax.swing.table.AbstractTableModel#setValueAt(java.lang.Object, * int, int) */ public void setValueAt(final Object arg0, final int y, final int x) { final String s = (String) arg0; final Readed r = readeds.get(y); if (x == 0) r.setReader(s); else { final String oldd = r.getDate(); try { r.setDate(s); } catch (final ParseException e) { try { JOptionPane.showMessageDialog(null, s + " - " + ResourceLoader.getString("not_a_date")); r.setDate(oldd); } catch (final ParseException e1) { e1.printStackTrace(); } } } }
Example #10
Source Project: openAGV Author: tcrct File: UserMessageHelper.java License: Apache License 2.0 | 6 votes |
private int translateType(Type type) { int jOptionType; switch (type) { case ERROR: jOptionType = JOptionPane.ERROR_MESSAGE; break; case INFO: jOptionType = JOptionPane.INFORMATION_MESSAGE; break; case QUESTION: jOptionType = JOptionPane.YES_NO_OPTION; break; default: jOptionType = JOptionPane.PLAIN_MESSAGE; } return jOptionType; }
Example #11
Source Project: Websocket-Smart-Card-Signer Author: damianofalcioni File: SignUI.java License: GNU Affero General Public License v3.0 | 5 votes |
public void sign(CertificateData certData, String pin){ if(signEngine.getNumDataToSign() == 0){ SignUtils.playBeeps(2); JOptionPane.showMessageDialog(null, "NO DATA TO SIGN", "ERROR", JOptionPane.ERROR_MESSAGE); return; } try { signEngine.sign(certData, pin); } catch (Exception e) { e.printStackTrace(); SignUtils.playBeeps(1); JOptionPane.showMessageDialog(null, "ERROR DURING THE SIGNING PROCESS:\n"+e.getMessage(), "ERROR", JOptionPane.ERROR_MESSAGE); } }
Example #12
Source Project: dctb-utfpr-2018-1 Author: diogocezar File: GerenciadorDeContaInterface.java License: Apache License 2.0 | 5 votes |
public static void main(String[] args) { Integer opcao = lerOpcaoDoMenu(); while(opcao != SAIR_DO_PROGRAMA){ switch(opcao){ case CRIAR_CONTA: criarNovaConta(); break; case CONSULTA_SALDO: consultarSaldo(); break; case CONSULTA_AGENCIA: consultarAgencia(); break; case ALTERAR_TITULAR: alterarNomeDoTitular(); break; case REMOVER_CONTA: removerConta(); break; case LISTAR_CONTAS: listarContas(); break; case SAIR_DO_PROGRAMA: JOptionPane.showMessageDialog(null,"[Programa será encerado!]"); break; default: JOptionPane.showMessageDialog(null,"Opcao Invalida!"); break; } opcao = lerOpcaoDoMenu(); } }
Example #13
Source Project: knopflerfish.org Author: knopflerfish File: JPrefsPanel.java License: BSD 3-Clause "New" or "Revised" License | 5 votes |
protected void doAddKey() { try { String name = JOptionPane.showInputDialog(this, "New key name", "New key...", JOptionPane.YES_NO_OPTION); if(name != null && !"".equals(name)) { node.put(name, node.get(name, "")); node.flush(); } setPreferences(node); } catch (Exception e) { Activator.log.warn("Failed to add key", e); } }
Example #14
Source Project: HackBar Author: d3vilbug File: Methods.java License: MIT License | 5 votes |
public static String prompt_and_validate_input(String prompt, String str){ String user_input = JOptionPane.showInputDialog(prompt, str); while(user_input.trim().equals("")){ user_input = JOptionPane.showInputDialog(prompt, str); } return user_input.trim(); }
Example #15
Source Project: magarena Author: magarena File: DuelDecksScreen.java License: GNU General Public License v3.0 | 5 votes |
private boolean confirmPlayWithInvalidDecks() { final String message = String.format("<html><b>%s</b><br><br>%s</html>", MText.get(_S15), MText.get(_S16) ); final Object[] params = {message}; final int n = JOptionPane.showConfirmDialog(screenContent, params, MText.get(_S17), JOptionPane.YES_NO_OPTION); return n == JOptionPane.YES_OPTION; }
Example #16
Source Project: Pydev Author: fabioz File: GraphView.java License: Eclipse Public License 1.0 | 5 votes |
private void createImage(String imageName) { if (graph == null) { return; } try { ImageWriter writer; writer = new ImageWriter(graph.getImage(null, GraphConstants.DEFAULTINSET), imageName); SwingUtilities.invokeLater(writer); } catch (Throwable e) { JOptionPane msgbox = new JOptionPane("Error writing file: " + e.getMessage()); msgbox.setVisible(true); } }
Example #17
Source Project: rcrs-server Author: roborescue File: ScenarioEditor.java License: BSD 3-Clause "New" or "Revised" License | 5 votes |
/** Set the map and scenario. @param newMap The new map. @param newScenario The new scenario. @throws CancelledByUserException If the user cancels the change due to unsaved changes. */ public void setScenario(GMLMap newMap, GisScenario newScenario) throws CancelledByUserException { checkForChanges(); if (!checkScenario(newMap, newScenario)) { JOptionPane.showMessageDialog(null, "The scenario file contained errors."); return; } map = newMap; scenario = newScenario; changed = false; viewer.setMap(map); inspector.setMap(map); updateOverlays(); }
Example #18
Source Project: PolyGlot Author: DraqueT File: InfoBox.java License: MIT License | 5 votes |
/** * Displays confirmation of user action * * @param title title of query message * @param message shown to user * @param parent parent caller * @return true if chooser accepts, false otherwise */ public static boolean actionConfirmation(String title, String message, Window parent) { PButton[] buttons = {YES, NO}; int option = POptionPane.internalShowOptionDialog(parent, message, title, JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE, UIManager.getIcon("OptionPane.questionIcon"), buttons, null); return option == JOptionPane.YES_OPTION; }
Example #19
Source Project: jeveassets Author: GoldenGnu File: Program.java License: GNU General Public License v2.0 | 5 votes |
/** * Used by macOsxCode() - should not be changed */ public void exit() { if (getStatusPanel().updateInProgress() > 0) { int value = JOptionPane.showConfirmDialog(getMainWindow().getFrame(), GuiFrame.get().exitMsg(getStatusPanel().updateInProgress()), GuiFrame.get().exitTitle(getStatusPanel().updateInProgress()), JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE); if (value != JOptionPane.OK_OPTION) { return; } } getStatusPanel().cancelUpdates(); saveExit(); LOG.info("Running shutdown hook(s) and exiting..."); System.exit(0); }
Example #20
Source Project: GpsPrune Author: activityworkshop File: RemoveAudioFunction.java License: GNU General Public License v2.0 | 5 votes |
/** * Perform the function */ public void begin() { // Delete the current audio, and optionally its point too, keeping undo information AudioClip currentAudio = _app.getTrackInfo().getCurrentAudio(); if (currentAudio != null) { // Audio is selected, see if it has a point or not boolean deleted = false; UndoDeleteAudio undoAction = null; if (currentAudio.getDataPoint() == null) { // no point attached, so just delete undoAction = new UndoDeleteAudio(currentAudio, _app.getTrackInfo().getSelection().getCurrentAudioIndex(), null, -1); deleted = _app.getTrackInfo().deleteCurrentAudio(false); } else { // point is attached, so need to confirm point deletion final int pointIndex = _app.getTrackInfo().getTrack().getPointIndex(currentAudio.getDataPoint()); undoAction = new UndoDeleteAudio(currentAudio, _app.getTrackInfo().getSelection().getCurrentAudioIndex(), currentAudio.getDataPoint(), pointIndex); undoAction.setAtBoundaryOfSelectedRange(pointIndex == _app.getTrackInfo().getSelection().getStart() || pointIndex == _app.getTrackInfo().getSelection().getEnd()); int response = JOptionPane.showConfirmDialog(_app.getFrame(), I18nManager.getText("dialog.deleteaudio.deletepoint"), I18nManager.getText(getNameKey()), JOptionPane.YES_NO_CANCEL_OPTION); boolean deletePointToo = (response == JOptionPane.YES_OPTION); // Cancel delete if cancel pressed or dialog closed if (response == JOptionPane.YES_OPTION || response == JOptionPane.NO_OPTION) { deleted = _app.getTrackInfo().deleteCurrentAudio(deletePointToo); } } // Add undo information to stack if necessary if (deleted) { _app.completeFunction(undoAction, currentAudio.getName() + " " + I18nManager.getText("confirm.media.removed")); } } }
Example #21
Source Project: jdal Author: chelu File: ViewCancelAction.java License: Apache License 2.0 | 5 votes |
/** * {@inheritDoc} */ public void actionPerformed(ActionEvent e) { if (getView().isDirty()) { if (JOptionPane.YES_OPTION == JOptionPane.showConfirmDialog(getView().getPanel(), getMessageWrapper().getMessage("ViewCancelAction.dirty"))) { getDialog().dispose(); } } else { getDialog().dispose(); } }
Example #22
Source Project: pcgen Author: PCGen File: Main.java License: GNU Lesser General Public License v2.1 | 5 votes |
/** * Check that the runtime environment is suitable for PCGen to run. */ private static void validateEnvironment(boolean useGui) { // Check our main folders are present String[] neededDirs = {ConfigurationSettings.getSystemsDir(), ConfigurationSettings.getPccFilesDir(), ConfigurationSettings.getPluginsDir(), ConfigurationSettings.getPreviewDir(), ConfigurationSettings.getOutputSheetsDir()}; StringBuilder missingDirs = new StringBuilder(); for (final String dirPath : neededDirs) { File dir = new File(dirPath); if (!dir.exists()) { String path = dirPath; try { path = dir.getCanonicalPath(); } catch (IOException e) { Logging.errorPrint("Unable to find canonical path for " + dir); } missingDirs.append(" ").append(path).append('\n'); } } if (missingDirs.length() > 0) { String message; message = "This installation of PCGen is missing the following required folders:\n" + missingDirs; Logging.errorPrint(message); if (useGui) { JOptionPane.showMessageDialog(null, message + "\nPlease reinstall PCGen.", Constants.APPLICATION_NAME, JOptionPane.ERROR_MESSAGE); } System.exit(1); } }
Example #23
Source Project: jeveassets Author: GoldenGnu File: LoadoutsTab.java License: GNU General Public License v2.0 | 5 votes |
private String getBuildName() { String buildName = JOptionInput.showInputDialog(program.getMainWindow().getFrame(), "Enter Build Name", "Export EFT", JOptionPane.PLAIN_MESSAGE); if (buildName == null) { return null; //Cancel } else if (buildName.isEmpty()) { JOptionPane.showMessageDialog(program.getMainWindow().getFrame(), TabsLoadout.get().name1(), TabsLoadout.get().empty(), JOptionPane.PLAIN_MESSAGE); return getBuildName(); } else { return buildName; } }
Example #24
Source Project: pgptool Author: pgptool File: EncryptOnePm.java License: GNU General Public License v3.0 | 5 votes |
private void notifyUserOfMissingKeysIfAny(Set<String> missedKeys, PropertyChangeEvent evt) { if (CollectionUtils.isEmpty(missedKeys)) { return; } UiUtils.messageBox(UiUtils.actionEvent(evt), text("error.notAllRecipientsAvailable", Arrays.asList(missedKeys)), text("term.attention"), JOptionPane.WARNING_MESSAGE); }
Example #25
Source Project: pcgen Author: PCGen File: PCGenActionMap.java License: GNU Lesser General Public License v2.1 | 5 votes |
@Override public void actionPerformed(ActionEvent e) { try { DesktopBrowserLauncher.viewInBrowser(new File(ConfigurationSettings.getDocsDir(), "index.html")); } catch (IOException ex) { Logging.errorPrint("Could not open docs in external browser", ex); JOptionPane.showMessageDialog(frame, LanguageBundle.getString("in_menuDocsNotOpenMsg"), LanguageBundle.getString("in_menuDocsNotOpenTitle"), JOptionPane.ERROR_MESSAGE); } }
Example #26
Source Project: beast-mcmc Author: beast-dev File: Utils.java License: GNU Lesser General Public License v2.1 | 5 votes |
private static void showExceptionDialog(Thread t, Throwable e, String message) { String msg = String.format("Unexpected problem on thread %s: %s" + "\n" + message, t.getName(), e.getMessage()); logException(t, e); JOptionPane.showMessageDialog(Utils.getActiveFrame(), // msg, // "Error", // JOptionPane.ERROR_MESSAGE, // Utils.createImageIcon(Utils.ERROR_ICON)); }
Example #27
Source Project: JavaMainRepo Author: JavaSummer File: BirdController.java License: Apache License 2.0 | 5 votes |
public void actionPerformed(ActionEvent e) { // new AddController(new AddFrame("Hummingbird"), true); String choice = JOptionPane.showInputDialog("Load animal or enter info? (load/enter)"); if (choice.equals("load")) { Animal animal = null; try { animal = speciesFactory.getAnimal(Constants.Animals.Birds.Hummingbird); } catch (Exception e2) { e2.printStackTrace(); } animalList.add(animal); try { animalRepo.save(animalList); } catch (FileNotFoundException | XMLStreamException e1) { e1.printStackTrace(); } } else if (choice.equals("enter")) { new AddController(new AddFrame("Hummingbird"), true); /* * */ } else { JOptionPane.showMessageDialog(frame, "Invalid choice.", "Warning", JOptionPane.WARNING_MESSAGE); } }
Example #28
Source Project: portecle Author: scop File: DGenerateKeyPair.java License: GNU General Public License v2.0 | 5 votes |
/** * Validate the key size value the user has entered as a string and convert it to an integer. Validate the key size * is supported for the particular key pair generation algorithm they have chosen. * * @return The Validity value or BAD_KEYSIZE if it is not valid */ private int validateKeySize() { String sKeySize = m_jcbKeySize.getSelectedItem().toString(); int iKeySize; if (sKeySize.isEmpty()) { JOptionPane.showMessageDialog(this, RB.getString("DGenerateKeyPair.KeySizeReq.message"), getTitle(), JOptionPane.WARNING_MESSAGE); return BAD_KEYSIZE; } try { iKeySize = Integer.parseInt(sKeySize); } catch (NumberFormatException ex) { JOptionPane.showMessageDialog(this, RB.getString("DGenerateKeyPair.KeySizeIntegerReq.message"), getTitle(), JOptionPane.WARNING_MESSAGE); return BAD_KEYSIZE; } if (m_jrbDSA.isSelected() && (iKeySize < 512 || iKeySize % 64 != 0)) { JOptionPane.showMessageDialog(this, RB.getString("DGenerateKeyPair.UnsupportedDsaKeySize.message"), getTitle(), JOptionPane.WARNING_MESSAGE); return BAD_KEYSIZE; } else if (iKeySize < 512) { JOptionPane.showMessageDialog(this, RB.getString("DGenerateKeyPair.UnsupportedRsaKeySize.message"), getTitle(), JOptionPane.WARNING_MESSAGE); return BAD_KEYSIZE; } return iKeySize; }
Example #29
Source Project: dctb-utfpr-2018-1 Author: diogocezar File: ManipulandoArquivo.java License: Apache License 2.0 | 5 votes |
private void mesagemUsuarioRecuperado(String recuperado) { JTextArea aux1 = new JTextArea(recuperado); JScrollPane aux = new JScrollPane(aux1){ @Override public Dimension getPreferredSize() { return new Dimension(250, 200); } }; JOptionPane.showMessageDialog(null, aux, "Usuario Encontrado", JOptionPane.INFORMATION_MESSAGE); }
Example #30
Source Project: dctb-utfpr-2018-1 Author: diogocezar File: Login.java License: Apache License 2.0 | 5 votes |
private void btnLoginActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnLoginActionPerformed if (!txtLogin.getText().isEmpty() && !txtPassword.getText().isEmpty()){ this.dispose(); new Home().setVisible(true); } else{ JOptionPane.showMessageDialog(null,"Digite login e senha"); } // TODO add your handling code here: }