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.tiempometa.muestradatos.JProgramTags.java
private void programButtonActionPerformed(ActionEvent e) { if (ReaderContext.isUsbConnected()) { if (ReaderContext.isUsbReading()) { ReaderContext.stopReading(); programButton.setText("Iniciar la programacin"); } else {//from ww w.j a v a 2 s .c o m try { if (lockCheckbox.isSelected() && (!validatePasswords())) { JOptionPane.showMessageDialog(this, "Se deben establecer contraseas de 8 caracteres [0-9],[a-f].", "Iniciar lectura", JOptionPane.ERROR_MESSAGE); return; } try { Integer.valueOf(nextChipnumberTextField.getText()); ReaderContext.startReading(); programButton.setText("Detener la programacin"); } catch (NumberFormatException e1) { JOptionPane.showMessageDialog(this, "Se debe establecer un valor para el siguiente chip.", "Iniciar lectura", JOptionPane.ERROR_MESSAGE); } } catch (ReaderException e1) { JOptionPane.showMessageDialog(this, "No se pudo iniciar la lectura.", "Iniciar lectura", JOptionPane.ERROR_MESSAGE); } } } }
From source file:it.imtech.configuration.StartWizard.java
/** * Creates a new wizard with active card (Select Language/Server) *///from ww w. j a v a2 s .c o m public StartWizard() { Globals.setGlobalVariables(); ResourceBundle bundle = ResourceBundle.getBundle(Globals.RESOURCES, Globals.CURRENT_LOCALE, Globals.loader); if (!checkAppDataFiles()) { JOptionPane.showMessageDialog(null, Utility.getBundleString("copy_appdata", bundle), Utility.getBundleString("copy_appdata_title", bundle), JOptionPane.ERROR_MESSAGE); System.exit(1); } DOMConfigurator.configure(Globals.LOG4J); logger = Logger.getLogger(StartWizard.class); logger.info("Starting Application Phaidra Importer"); mainFrame = new JFrame(); if (Utility.internetConnectionAvailable()) { Globals.ONLINE = true; } it.imtech.utility.Utility.cleanUndoDir(); XMLConfiguration internalConf = setConfiguration(); logger.info("Configuration path estabilished"); XMLConfiguration config = setConfigurationPaths(internalConf, bundle); headerPanel = new HeaderPanel(); footerPanel = new FooterPanel(); JButton nextButton = (JButton) footerPanel.getComponentByName("next_button"); JButton prevButton = (JButton) footerPanel.getComponentByName("prev_button"); nextButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { if (getCurrentCard() instanceof ChooseServer) { ResourceBundle bundle = ResourceBundle.getBundle(Globals.RESOURCES, Globals.CURRENT_LOCALE, Globals.loader); try { mainFrame.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); Server selected = chooseServer.getSelectedServer(); logger.info("Selected Server = " + selected.getServername()); SelectedServer.getInstance(null).makeEmpty(); SelectedServer.getInstance(selected); if (Globals.ONLINE) { logger.info("Testing server connection..."); ChooseServer.testServerConnection(SelectedServer.getInstance(null).getBaseUrl()); } chooseFolder.updateLanguage(); MetaUtility.getInstance().preInitializeData(); logger.info("Preinitialization done (Vocabulary and Languages"); c1.next(cardsPanel); mainFrame.setCursor(null); } catch (Exception ex) { logger.error(ex.getMessage()); JOptionPane.showMessageDialog(new Frame(), Utility.getBundleString("preinitializemetadataex", bundle)); } } else if (getCurrentCard() instanceof ChooseFolder) { mainFrame.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); boolean error = chooseFolder.checkFolderSelectionValidity(); if (error == false) { BookImporter x = BookImporter.getInstance(); mainFrame.setCursor(null); mainFrame.setVisible(false); } } } }); prevButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { if (getCurrentCard() instanceof ChooseServer) { ResourceBundle bundle = ResourceBundle.getBundle(Globals.RESOURCES, Globals.CURRENT_LOCALE, Globals.loader); String title = Utility.getBundleString("dialog_1_title", bundle); String text = Utility.getBundleString("dialog_1", bundle); ConfirmDialog confirm = new ConfirmDialog(mainFrame, true, title, text, Utility.getBundleString("confirm", bundle), Utility.getBundleString("back", bundle)); confirm.setVisible(true); boolean close = confirm.getChoice(); confirm.dispose(); if (close == true) { mainFrame.dispose(); } } else { c1.previous(cardsPanel); } } }); cardsPanel = new JPanel(new CardLayout()); cardsPanel.setBackground(Color.WHITE); chooseServer = new ChooseServer(config); chooseFolder = new ChooseFolder(); cardsPanel.add(chooseServer, "1"); cardsPanel.add(chooseFolder, "2"); cardsPanel.setLayout(c1); c1.show(cardsPanel, "1"); //Main Panel style mainPanel = new JPanel(new BorderLayout()); mainPanel.add(BorderLayout.NORTH, headerPanel); mainPanel.add(BorderLayout.CENTER, cardsPanel); mainPanel.add(BorderLayout.PAGE_END, footerPanel); mainFrame.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); mainFrame.addWindowListener(new java.awt.event.WindowAdapter() { @Override public void windowClosing(java.awt.event.WindowEvent windowEvent) { ResourceBundle bundle = ResourceBundle.getBundle(Globals.RESOURCES, Globals.CURRENT_LOCALE, Globals.loader); String title = Utility.getBundleString("dialog_1_title", bundle); String text = Utility.getBundleString("dialog_1", bundle); ConfirmDialog confirm = new ConfirmDialog(mainFrame, true, title, text, Utility.getBundleString("confirm", bundle), Utility.getBundleString("back", bundle)); confirm.setVisible(true); boolean close = confirm.getChoice(); confirm.dispose(); if (close == true) { mainFrame.dispose(); } } }); //Add Style mainFrame.getContentPane().setBackground(Color.white); mainFrame.getContentPane().setLayout(new BorderLayout()); mainFrame.getContentPane().setPreferredSize(new Dimension(640, 400)); mainFrame.getContentPane().add(BorderLayout.CENTER, mainPanel); mainFrame.pack(); //Center frame in the screen Dimension dim = Toolkit.getDefaultToolkit().getScreenSize(); int x = (dim.width - mainFrame.getSize().width) / 2; int y = (dim.height - mainFrame.getSize().height) / 2; mainFrame.setLocation(x, y); mainFrame.setVisible(true); }
From source file:latexstudio.editor.remote.UploadToDropbox.java
@Override public void actionPerformed(ActionEvent e) { DbxClient client = DbxUtil.getDbxClient(); if (client == null) { return;/* www. ja va 2s. c om*/ } String sourceFileName = ApplicationUtils.getTempSourceFile(); File file = new File(sourceFileName); FileInputStream inputStream = null; try { inputStream = new FileInputStream(file); } catch (FileNotFoundException ex) { Exceptions.printStackTrace(ex); } String defaultFileName = etc.getCurrentFile() == null ? "welcome.tex" : etc.getCurrentFile().getName(); String fileName = (String) JOptionPane.showInputDialog(null, "Please enter file name", "Upload file", JOptionPane.INFORMATION_MESSAGE, null, null, defaultFileName); if (fileName != null) { fileName = fileName.endsWith(TEX_EXTENSION) ? fileName : fileName.concat(TEX_EXTENSION); try { DbxEntry.File uploadedFile = client.uploadFile("/OpenLaTeXStudio/" + fileName, DbxWriteMode.add(), file.length(), inputStream); JOptionPane.showMessageDialog(null, "Successfuly uploaded file " + uploadedFile.name + " (" + uploadedFile.humanSize + ")", "File uploaded to Dropbox", JOptionPane.INFORMATION_MESSAGE); revtc.close(); } catch (DbxException ex) { DbxUtil.showDbxAccessDeniedPrompt(); } catch (IOException ex) { Exceptions.printStackTrace(ex); } finally { IOUtils.closeQuietly(inputStream); } } }
From source file:edu.smc.mediacommons.panels.PasswordPanel.java
public PasswordPanel() { setLayout(null);//from w w w .java 2 s . c o m add(Utils.createLabel("Enter a Password to Test", 60, 30, 200, 20, null)); final JButton test = Utils.createButton("Test", 260, 50, 100, 20, null); add(test); final JPasswordField fieldPassword = new JPasswordField(32); fieldPassword.setBounds(60, 50, 200, 20); add(fieldPassword); final PieDataset dataset = createSampleDataset(33, 33, 33); final JFreeChart chart = createChart(dataset); final ChartPanel chartPanel = new ChartPanel(chart); chartPanel.setPreferredSize(new java.awt.Dimension(300, 300)); chartPanel.setBounds(45, 80, 340, 250); add(chartPanel); test.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { String password = new String(fieldPassword.getPassword()); if (password.isEmpty() || password == null) { JOptionPane.showMessageDialog(getParent(), "Warning! The input was blank!", "Invalid Input", JOptionPane.ERROR_MESSAGE); } else { int letterCount = 0, numberCount = 0, specialCount = 0, total = password.length(); for (char c : password.toCharArray()) { if (Character.isLetter(c)) { letterCount++; } else if (Character.isDigit(c)) { numberCount++; } else { specialCount++; } } long totalCombinations = 0; double percentLetters = 0; double percentNumbers = 0; double percentCharacters = 0; if (letterCount > 0) { totalCombinations += (factorial(26) / factorial(26 - letterCount)); percentLetters = (letterCount + 0.0 / total); } if (numberCount > 0) { totalCombinations += (factorial(10) / factorial(10 - numberCount)); percentNumbers = (numberCount + 0.0 / total); } if (specialCount > 0) { totalCombinations += (factorial(40) / factorial(40 - specialCount)); percentCharacters = (specialCount + 0.0 / total); } PieDataset dataset = createSampleDataset(percentLetters, percentNumbers, percentCharacters); JFreeChart chart = createChart(dataset); chartPanel.setChart(chart); JOptionPane.showMessageDialog(getParent(), "Total Combinations: " + totalCombinations + "\nAssuming Rate Limited, Single: " + (totalCombinations / 1000) + " seconds" + "\n\nBreakdown:\nLetters: " + percentLetters + "%\nNumbers: " + percentNumbers + "%\nCharacters: " + percentCharacters + "%"); } } }); setVisible(true); }
From source file:EnrollFingerprint.Verify.java
/** * Creates new form Enroll//from ww w . jav a 2s.co m */ public Verify() { initComponents(); //updateStatus(); // Event listener actived when fingerprint template is ready this.addPropertyChangeListener(TEMPLATE_PROPERTY, new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { if (evt.getNewValue() == evt.getOldValue()) { return; } if (template != null) { JOptionPane.showMessageDialog(Verify.this, "La huella capturada esta lista para ser guardada.", "Captura y Registro de huellas", JOptionPane.INFORMATION_MESSAGE); } } }); }
From source file:be.fedict.eid.tsl.Pkcs11Token.java
public List<String> getAliases() throws KeyStoreException, NoSuchAlgorithmException, CertificateException, IOException, UnrecoverableEntryException { List<String> aliases = new LinkedList<String>(); try {/*from ww w.j a v a2 s . co m*/ this.keyStore = KeyStore.getInstance("PKCS11", this.pkcs11Provider); } catch (KeyStoreException e) { JOptionPane.showMessageDialog(null, "No keystore present: " + e.getMessage(), "PKCS#11 error", JOptionPane.ERROR_MESSAGE); throw e; } LoadStoreParameter loadStoreParameter = new Pkcs11LoadStoreParameter(); try { this.keyStore.load(loadStoreParameter); } catch (IOException e) { LOG.debug("I/O error: " + e.getMessage(), e); Throwable cause = e.getCause(); if (null != cause) { if (cause instanceof FailedLoginException) { JOptionPane.showMessageDialog(null, "PIN incorrect", "Login failed", JOptionPane.ERROR_MESSAGE); } } return aliases; } Enumeration<String> aliasesEnum = this.keyStore.aliases(); while (aliasesEnum.hasMoreElements()) { String alias = aliasesEnum.nextElement(); LOG.debug("keystore alias: " + alias); if (false == this.keyStore.isKeyEntry(alias)) { continue; } aliases.add(alias); } return aliases; }
From source file:edu.harvard.i2b2.query.serviceClient.QueryListNamesClient.java
public static String sendQueryRequestREST(String XMLstr) { try {/*w w w. j a v a 2 s . com*/ MessageUtil.getInstance().setRequest("URL: " + getCRCNavigatorQueryProcessorServiceName(), XMLstr); OMElement payload = getQueryPayLoad(XMLstr); Options options = new Options(); targetEPR = new EndpointReference(getCRCNavigatorQueryProcessorServiceName()); options.setTo(targetEPR); options.setTo(targetEPR); options.setTransportInProtocol(Constants.TRANSPORT_HTTP); options.setProperty(Constants.Configuration.ENABLE_REST, Constants.VALUE_TRUE); options.setProperty(HTTPConstants.SO_TIMEOUT, new Integer(10000)); options.setProperty(HTTPConstants.CONNECTION_TIMEOUT, new Integer(10000)); ServiceClient sender = new ServiceClient(); sender.setOptions(options); OMElement result = sender.sendReceive(payload); // System.out.println("Response XML: "+result.toString()); MessageUtil.getInstance().setResponse("URL: " + getCRCNavigatorQueryProcessorServiceName(), result.toString()); return result.toString(); } catch (AxisFault axisFault) { axisFault.printStackTrace(); java.awt.EventQueue.invokeLater(new Runnable() { public void run() { JOptionPane.showMessageDialog(null, "Trouble with connection to the remote server, " + "this is often a network error, please try again", "Network Error", JOptionPane.INFORMATION_MESSAGE); } }); return null; } catch (Exception e) { e.printStackTrace(); return null; } }
From source file:edu.harvard.i2b2.query.ui.QueryListNamesClient.java
public static String sendQueryRequestREST(String XMLstr) { try {//from www .j av a 2s.com MessageUtil.getInstance() .setRequest("URL: " + getCRCNavigatorQueryProcessorServiceName() + "\n" + XMLstr); OMElement payload = getQueryPayLoad(XMLstr); Options options = new Options(); targetEPR = new EndpointReference(getCRCNavigatorQueryProcessorServiceName()); options.setTo(targetEPR); options.setTo(targetEPR); options.setTransportInProtocol(Constants.TRANSPORT_HTTP); options.setProperty(Constants.Configuration.ENABLE_REST, Constants.VALUE_TRUE); options.setProperty(HTTPConstants.SO_TIMEOUT, new Integer(10000)); options.setProperty(HTTPConstants.CONNECTION_TIMEOUT, new Integer(10000)); ServiceClient sender = new ServiceClient(); sender.setOptions(options); OMElement result = sender.sendReceive(payload); // System.out.println("Response XML: "+result.toString()); MessageUtil.getInstance() .setResponse("URL: " + getCRCNavigatorQueryProcessorServiceName() + "\n" + result.toString()); return result.toString(); } catch (AxisFault axisFault) { axisFault.printStackTrace(); java.awt.EventQueue.invokeLater(new Runnable() { public void run() { JOptionPane.showMessageDialog(null, "Trouble with connection to the remote server, " + "this is often a network error, please try again", "Network Error", JOptionPane.INFORMATION_MESSAGE); } }); return null; } catch (Exception e) { e.printStackTrace(); return null; } }
From source file:au.org.ala.delta.intkey.ui.RealInputDialog.java
@Override void handleBtnOKClicked() { String inputTxt = _txtInput.getText(); if (inputTxt.length() > 0) { try {// w ww . j a va2s. c om _inputData = ParsingUtils.parseRealCharacterValue(inputTxt); setVisible(false); } catch (IllegalArgumentException ex) { JOptionPane.showMessageDialog(this, validationErrorMessage, validationErrorTitle, JOptionPane.ERROR_MESSAGE); } } else { // return a float range with negative infinity. This represents // "no values selected". _inputData = new FloatRange(Float.NEGATIVE_INFINITY); setVisible(false); } }
From source file:net.mohatu.bloocoin.miner.RegCustom.java
private void register() { try {// ww w . j av a 2 s. c om String result = new String(); Socket sock = new Socket(this.url, this.port); String command = "{\"cmd\":\"register" + "\",\"addr\":\"" + addr + "\",\"pwd\":\"" + key + "\"}"; DataInputStream is = new DataInputStream(sock.getInputStream()); DataOutputStream os = new DataOutputStream(sock.getOutputStream()); os.write(command.getBytes()); os.flush(); BufferedReader in = new BufferedReader(new InputStreamReader(is)); String inputLine; while ((inputLine = in.readLine()) != null) { result += inputLine; } is.close(); os.close(); sock.close(); System.out.println(result); if (result.contains("\"success\": true")) { System.out.println("Registration successful: " + addr); saveBloostamp(); } else if (result.contains("\"success\": false")) { System.out.println("Result: Failed"); JOptionPane.showMessageDialog(Main.scrollPane, "Registration failed.\nCheck your network connection", "Registration Failed", JOptionPane.ERROR_MESSAGE); System.exit(0); } } catch (UnknownHostException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } }