List of usage examples for javax.swing JOptionPane WARNING_MESSAGE
int WARNING_MESSAGE
To view the source code for javax.swing JOptionPane WARNING_MESSAGE.
Click Source Link
From source file:org.apache.shiro.samples.spring.ui.WebStartView.java
public void actionPerformed(ActionEvent e) { try {//from w ww . j a v a2 s . c o m if (e.getSource() == saveButton) { sampleManager.setValue(valueField.getText()); } else if (e.getSource() == refreshButton) { updateValueLabel(); } else if (e.getSource() == secureMethod1Button) { sampleManager.secureMethod1(); JOptionPane.showMessageDialog(frame, "Method #1 successfully called.", "Success", JOptionPane.INFORMATION_MESSAGE); } else if (e.getSource() == secureMethod2Button) { sampleManager.secureMethod2(); JOptionPane.showMessageDialog(frame, "Method #2 successfully called.", "Success", JOptionPane.INFORMATION_MESSAGE); } else if (e.getSource() == secureMethod3Button) { sampleManager.secureMethod3(); JOptionPane.showMessageDialog(frame, "Method #3 successfully called.", "Success", JOptionPane.INFORMATION_MESSAGE); } else { throw new RuntimeException("Unexpected action event from source: " + e.getSource()); } } catch (AuthorizationException ae) { JOptionPane.showMessageDialog(frame, "Unauthorized to perform action: " + ae.getMessage(), "Unauthorized", JOptionPane.WARNING_MESSAGE); } }
From source file:es.mityc.firmaJava.libreria.pkcs7.ValidaTarjeta.java
/** * This method initializes //from www .j a v a2s .c o m * */ public ValidaTarjeta(Frame parent) { super(parent, true); initialize(); //Carga la configuracin configuracion.cargarConfiguracion(); //Establece el idioma segn la configuracin String locale = configuracion.getValor(LOCALE); FileInputStream fis = null; // Configura el idioma I18n.setLocale(locale, locale.toUpperCase()); try { fis = new FileInputStream(TARJETAS_PROPERTIES); tarjetasLibrerias.load(fis); Collection claves = tarjetasLibrerias.keySet(); jTarjetaComboBox.addItem(I18n.getResource(LIBRERIAXADES_VALIDARTARJETA_TEXTO_1)); for (Iterator iter = claves.iterator(); iter.hasNext();) { jTarjetaComboBox.addItem((String) iter.next()); } jTarjetaComboBox.addItem(I18n.getResource(LIBRERIAXADES_VALIDARTARJETA_TEXTO_2)); } catch (IOException e) { JOptionPane.showMessageDialog(this, I18n.getResource(LIBRERIAXADES_VALIDARTARJETA_TEXTO_3) + TARJETAS_PROPERTIES, I18n.getResource(LIBRERIAXADES_VALIDARTARJETA_TEXTO_4), JOptionPane.WARNING_MESSAGE); } finally { try { fis.close(); } catch (IOException e) { logger.error(e); } } }
From source file:hspc.submissionsprogram.AppDisplay.java
AppDisplay() { this.setTitle("Dominion High School Programming Contest"); this.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); this.setResizable(false); WindowListener exitListener = new WindowAdapter() { @Override//from ww w.j av a2s. c o m public void windowClosing(WindowEvent e) { System.exit(0); } }; this.addWindowListener(exitListener); JTabbedPane pane = new JTabbedPane(); this.add(pane); JPanel submitPanel = new JPanel(null); submitPanel.setPreferredSize(new Dimension(500, 500)); UIManager.put("FileChooser.readOnly", true); JFileChooser fileChooser = new JFileChooser(); fileChooser.setBounds(0, 0, 500, 350); fileChooser.setVisible(true); FileNameExtensionFilter javaFilter = new FileNameExtensionFilter("Java files (*.java)", "java"); fileChooser.setFileFilter(javaFilter); fileChooser.setAcceptAllFileFilterUsed(false); fileChooser.setControlButtonsAreShown(false); submitPanel.add(fileChooser); JSeparator separator1 = new JSeparator(); separator1.setBounds(12, 350, 476, 2); separator1.setForeground(new Color(122, 138, 152)); submitPanel.add(separator1); JLabel problemChooserLabel = new JLabel("Problem:"); problemChooserLabel.setBounds(12, 360, 74, 25); submitPanel.add(problemChooserLabel); String[] listOfProblems = Main.Configuration.get("problem_names") .split(Main.Configuration.get("name_delimiter")); JComboBox problems = new JComboBox<>(listOfProblems); problems.setBounds(96, 360, 393, 25); submitPanel.add(problems); JButton submit = new JButton("Submit"); submit.setBounds(170, 458, 160, 30); submit.addActionListener(e -> { try { File file = fileChooser.getSelectedFile(); try { CloseableHttpClient httpClient = HttpClients.createDefault(); HttpPost uploadFile = new HttpPost(Main.Configuration.get("submit_url")); MultipartEntityBuilder builder = MultipartEntityBuilder.create(); builder.addTextBody("accountID", Main.accountID, ContentType.TEXT_PLAIN); builder.addTextBody("problem", String.valueOf(problems.getSelectedItem()), ContentType.TEXT_PLAIN); builder.addBinaryBody("submission", file, ContentType.APPLICATION_OCTET_STREAM, file.getName()); HttpEntity multipart = builder.build(); uploadFile.setEntity(multipart); CloseableHttpResponse response = httpClient.execute(uploadFile); HttpEntity responseEntity = response.getEntity(); String inputLine; BufferedReader br = new BufferedReader(new InputStreamReader(responseEntity.getContent())); try { if ((inputLine = br.readLine()) != null) { int rowIndex = Integer.parseInt(inputLine); new ResultWatcher(rowIndex); } br.close(); } catch (IOException ex) { ex.printStackTrace(); } } catch (Exception ex) { ex.printStackTrace(); } } catch (NullPointerException ex) { JOptionPane.showMessageDialog(this, "No file selected.\nPlease select a java file.", "Error", JOptionPane.WARNING_MESSAGE); } }); submitPanel.add(submit); JPanel clarificationsPanel = new JPanel(null); clarificationsPanel.setPreferredSize(new Dimension(500, 500)); cList = new JList<>(); cList.setBounds(12, 12, 476, 200); cList.setBorder(new CompoundBorder(BorderFactory.createLineBorder(new Color(122, 138, 152)), BorderFactory.createEmptyBorder(8, 8, 8, 8))); cList.setBackground(new Color(254, 254, 255)); clarificationsPanel.add(cList); JButton viewC = new JButton("View"); viewC.setBounds(12, 224, 232, 25); viewC.addActionListener(e -> { if (cList.getSelectedIndex() != -1) { int id = Integer.parseInt(cList.getSelectedValue().split("\\.")[0]); clarificationDatas.stream().filter(data -> data.getId() == id).forEach( data -> new ClarificationDisplay(data.getProblem(), data.getText(), data.getResponse())); } }); clarificationsPanel.add(viewC); JButton refreshC = new JButton("Refresh"); refreshC.setBounds(256, 224, 232, 25); refreshC.addActionListener(e -> updateCList(true)); clarificationsPanel.add(refreshC); JSeparator separator2 = new JSeparator(); separator2.setBounds(12, 261, 476, 2); separator2.setForeground(new Color(122, 138, 152)); clarificationsPanel.add(separator2); JLabel problemChooserLabelC = new JLabel("Problem:"); problemChooserLabelC.setBounds(12, 273, 74, 25); clarificationsPanel.add(problemChooserLabelC); JComboBox problemsC = new JComboBox<>(listOfProblems); problemsC.setBounds(96, 273, 393, 25); clarificationsPanel.add(problemsC); JTextArea textAreaC = new JTextArea(); textAreaC.setLineWrap(true); textAreaC.setWrapStyleWord(true); textAreaC.setBorder(new CompoundBorder(BorderFactory.createLineBorder(new Color(122, 138, 152)), BorderFactory.createEmptyBorder(8, 8, 8, 8))); textAreaC.setBackground(new Color(254, 254, 255)); JScrollPane areaScrollPane = new JScrollPane(textAreaC); areaScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); areaScrollPane.setBounds(12, 312, 477, 134); clarificationsPanel.add(areaScrollPane); JButton submitC = new JButton("Submit Clarification"); submitC.setBounds(170, 458, 160, 30); submitC.addActionListener(e -> { if (textAreaC.getText().length() > 2048) { JOptionPane.showMessageDialog(this, "Clarification body is too long.\nMaximum of 2048 characters allowed.", "Error", JOptionPane.WARNING_MESSAGE); } else if (textAreaC.getText().length() < 20) { JOptionPane.showMessageDialog(this, "Clarification body is too short.\nClarifications must be at least 20 characters, but no more than 2048.", "Error", JOptionPane.WARNING_MESSAGE); } else { Connection conn = null; PreparedStatement stmt = null; try { Class.forName(JDBC_DRIVER); conn = DriverManager.getConnection(Main.Configuration.get("jdbc_mysql_address"), Main.Configuration.get("mysql_user"), Main.Configuration.get("mysql_pass")); String sql = "INSERT INTO clarifications (team, problem, text) VALUES (?, ?, ?)"; stmt = conn.prepareStatement(sql); stmt.setInt(1, Integer.parseInt(String.valueOf(Main.accountID))); stmt.setString(2, String.valueOf(problemsC.getSelectedItem())); stmt.setString(3, String.valueOf(textAreaC.getText())); textAreaC.setText(""); stmt.executeUpdate(); stmt.close(); conn.close(); updateCList(false); } catch (Exception ex) { ex.printStackTrace(); } finally { try { if (stmt != null) { stmt.close(); } } catch (Exception ex2) { ex2.printStackTrace(); } try { if (conn != null) { conn.close(); } } catch (Exception ex2) { ex2.printStackTrace(); } } } }); clarificationsPanel.add(submitC); pane.addTab("Submit", submitPanel); pane.addTab("Clarifications", clarificationsPanel); Timer timer = new Timer(); TimerTask updateTask = new TimerTask() { @Override public void run() { updateCList(false); } }; timer.schedule(updateTask, 10000, 10000); updateCList(false); this.pack(); this.setLocationRelativeTo(null); this.setVisible(true); }
From source file:com.edduarte.protbox.core.registry.PbxFile.java
public void setBackupPolicy(BackupPolicy backupPolicy) { if (!backupPolicy.equals(BackupPolicy.Ask)) { boolean changeBackupPolicy = true; if (snapshotStack.size() > backupPolicy.maxBackupSize) { changeBackupPolicy = JOptionPane.showConfirmDialog(null, "The number of stored backup copies have been reduced to " + backupPolicy.maxBackupSize + ", and prior backups above that number will be deleted.\n" + "Are you sure you want to change the backup policy?", "Confirm backup policy change", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE) == JOptionPane.YES_NO_OPTION; }//from w w w . jav a 2 s . c o m if (changeBackupPolicy) { this.backupPolicy = backupPolicy; while (snapshotStack.size() > backupPolicy.maxBackupSize) { snapshotStack.removeLast(); } } } else { this.backupPolicy = backupPolicy; } }
From source file:ca.sqlpower.wabit.enterprise.client.ServerInfoProvider.java
private static void init(String host, String port, String path, String username, String password) throws IOException { URL serverInfoUrl = toServerInfoURL(host, port, path); if (version.containsKey(generateServerKey(host, port, path, username, password))) return;/*from ww w . jav a 2 s .c o m*/ try { HttpParams params = new BasicHttpParams(); HttpConnectionParams.setConnectionTimeout(params, 2000); DefaultHttpClient httpClient = new DefaultHttpClient(params); httpClient.setCookieStore(WabitClientSession.getCookieStore()); httpClient.getCredentialsProvider().setCredentials( new AuthScope(serverInfoUrl.getHost(), AuthScope.ANY_PORT), new UsernamePasswordCredentials(username, password)); HttpUriRequest request = new HttpOptions(serverInfoUrl.toURI()); String responseBody = httpClient.execute(request, new BasicResponseHandler()); // Decode the message String serverVersion; Boolean licensedServer; final String watermarkMessage; try { JSONObject jsonObject = new JSONObject(responseBody); serverVersion = jsonObject.getString(ServerProperties.SERVER_VERSION.toString()); licensedServer = jsonObject.getBoolean(ServerProperties.SERVER_LICENSED.toString()); watermarkMessage = jsonObject.getString(ServerProperties.SERVER_WATERMARK_MESSAGE.toString()); } catch (JSONException e) { throw new IOException(e.getMessage()); } // Save found values version.put(generateServerKey(host, port, path, username, password), new Version(serverVersion)); licenses.put(generateServerKey(host, port, path, username, password), licensedServer); watermarkMessages.put(generateServerKey(host, port, path, username, password), watermarkMessage); // Notify the user if the server is not licensed. if (!licensedServer) { SwingUtilities.invokeLater(new Runnable() { public void run() { JOptionPane.showMessageDialog(null, watermarkMessage, "SQL Power Wabit Server License", JOptionPane.WARNING_MESSAGE); } }); } // Now get the available fonts. URL serverFontsURL = toServerFontsURL(host, port, path); HttpUriRequest fontsRequest = new HttpGet(serverFontsURL.toURI()); String fontsResponseBody = httpClient.execute(fontsRequest, new BasicResponseHandler()); try { JSONArray fontsArray = new JSONArray(fontsResponseBody); List<String> fontNames = new ArrayList<String>(); for (int i = 0; i < fontsArray.length(); i++) { fontNames.add(fontsArray.getString(i)); } // Sort the list. Collections.sort(fontNames); fonts.put(generateServerKey(host, port, path, username, password), fontNames); } catch (JSONException e) { throw new IOException(e.getMessage()); } } catch (URISyntaxException e) { throw new IOException(e.getLocalizedMessage()); } }
From source file:frames.consulta.java
void captura() { int filase = tblconsulta.getSelectedRow(); try {//from w ww.j av a 2 s . c o m String cedula, nombre, ape, edad, direccion; if (filase == -1) { JOptionPane.showMessageDialog(null, "Debe Seleccionar un Paciente", "Advertencia", JOptionPane.WARNING_MESSAGE); } else { modelo = (DefaultTableModel) tblconsulta.getModel(); cedula = tblconsulta.getValueAt(filase, 0).toString(); nombre = tblconsulta.getValueAt(filase, 1).toString(); ape = tblconsulta.getValueAt(filase, 2).toString(); edad = tblconsulta.getValueAt(filase, 3).toString(); direccion = tblconsulta.getValueAt(filase, 4).toString(); new modificarhistoria().setVisible(true); modificarhistoria.txtcedula.setText(cedula); modificarhistoria.txtnombre.setText(nombre); modificarhistoria.txtapellido.setText(ape); modificarhistoria.txtedad.setText(edad); //this.setVisible(false); BuscarpacienteEditar(cedula); } } catch (Exception e) { //registro.action = "Ver"; } }
From source file:net.sf.keystore_explorer.gui.actions.ExportKeyPairPrivateKeyAction.java
private void exportAsPkcs8(PrivateKey privateKey, String alias) throws CryptoException, IOException { File exportFile = null;/*from www . j a v a2 s.c o m*/ try { DExportPrivateKeyPkcs8 dExportPrivateKeyPkcs8 = new DExportPrivateKeyPkcs8(frame, alias, applicationSettings.getPasswordQualityConfig()); dExportPrivateKeyPkcs8.setLocationRelativeTo(frame); dExportPrivateKeyPkcs8.setVisible(true); if (!dExportPrivateKeyPkcs8.exportSelected()) { return; } exportFile = dExportPrivateKeyPkcs8.getExportFile(); boolean pemEncode = dExportPrivateKeyPkcs8.pemEncode(); boolean encrypt = dExportPrivateKeyPkcs8.encrypt(); Pkcs8PbeType pbeAlgorithm = null; Password exportPassword = null; if (encrypt) { pbeAlgorithm = dExportPrivateKeyPkcs8.getPbeAlgorithm(); exportPassword = dExportPrivateKeyPkcs8.getExportPassword(); } byte[] encoded = getPkcs8EncodedPrivateKey(privateKey, pemEncode, pbeAlgorithm, exportPassword); exportEncodedPrivateKey(encoded, exportFile); JOptionPane.showMessageDialog(frame, res.getString("ExportKeyPairPrivateKeyAction.ExportPrivateKeyPkcs8Successful.message"), res.getString("ExportKeyPairPrivateKeyAction.ExportPrivateKeyPkcs8.Title"), JOptionPane.INFORMATION_MESSAGE); } catch (FileNotFoundException ex) { String message = MessageFormat .format(res.getString("ExportKeyPairPrivateKeyAction.NoWriteFile.message"), exportFile); JOptionPane.showMessageDialog(frame, message, res.getString("ExportKeyPairPrivateKeyAction.ExportPrivateKeyPkcs8.Title"), JOptionPane.WARNING_MESSAGE); } }
From source file:com.tiempometa.muestradatos.JReadTags.java
private void closeButtonActionPerformed(ActionEvent e) { if (ReaderContext.isUsbConnected()) { if (ReaderContext.isUsbReading()) { JOptionPane.showMessageDialog(this, "Se debe detener la lectura primero", "Alerta", JOptionPane.WARNING_MESSAGE); return; }// w w w.ja va 2s.c o m } this.dispose(); }
From source file:net.sf.keystore_explorer.gui.actions.GenerateCsrAction.java
/** * Do action.//from ww w . ja v a 2 s .c o m */ @Override protected void doAction() { File csrFile = null; FileOutputStream fos = null; try { KeyStoreHistory history = kseFrame.getActiveKeyStoreHistory(); KeyStoreState currentState = history.getCurrentState(); Provider provider = history.getExplicitProvider(); String alias = kseFrame.getSelectedEntryAlias(); Password password = getEntryPassword(alias, currentState); if (password == null) { return; } KeyStore keyStore = currentState.getKeyStore(); PrivateKey privateKey = (PrivateKey) keyStore.getKey(alias, password.toCharArray()); String keyPairAlg = privateKey.getAlgorithm(); KeyPairType keyPairType = KeyPairUtil.getKeyPairType(privateKey); if (keyPairType == null) { throw new CryptoException(MessageFormat .format(res.getString("GenerateCsrAction.NoCsrForKeyPairAlg.message"), keyPairAlg)); } // determine dir of current keystore as proposal for CSR file location String path = CurrentDirectory.get().getAbsolutePath(); File keyStoreFile = history.getFile(); if (keyStoreFile != null) { path = keyStoreFile.getAbsoluteFile().getParent(); } DGenerateCsr dGenerateCsr = new DGenerateCsr(frame, alias, privateKey, keyPairType, path, provider); dGenerateCsr.setLocationRelativeTo(frame); dGenerateCsr.setVisible(true); if (!dGenerateCsr.generateSelected()) { return; } CsrType format = dGenerateCsr.getFormat(); SignatureType signatureType = dGenerateCsr.getSignatureType(); String challenge = dGenerateCsr.getChallenge(); String unstructuredName = dGenerateCsr.getUnstructuredName(); boolean useCertificateExtensions = dGenerateCsr.isAddExtensionsWanted(); csrFile = dGenerateCsr.getCsrFile(); X509Certificate firstCertInChain = X509CertUtil .orderX509CertChain(X509CertUtil.convertCertificates(keyStore.getCertificateChain(alias)))[0]; fos = new FileOutputStream(csrFile); if (format == CsrType.PKCS10) { String csr = Pkcs10Util.getCsrEncodedDerPem(Pkcs10Util.generateCsr(firstCertInChain, privateKey, signatureType, challenge, unstructuredName, useCertificateExtensions, provider)); fos.write(csr.getBytes()); } else { SpkacSubject subject = new SpkacSubject( X500NameUtils.x500PrincipalToX500Name(firstCertInChain.getSubjectX500Principal())); PublicKey publicKey = firstCertInChain.getPublicKey(); // TODO handle other providers (PKCS11 etc) Spkac spkac = new Spkac(challenge, signatureType, subject, publicKey, privateKey); spkac.output(fos); } } catch (FileNotFoundException ex) { JOptionPane.showMessageDialog(frame, MessageFormat.format(res.getString("GenerateCsrAction.NoWriteFile.message"), csrFile), res.getString("GenerateCsrAction.GenerateCsr.Title"), JOptionPane.WARNING_MESSAGE); return; } catch (Exception ex) { DError.displayError(frame, ex); return; } finally { IOUtils.closeQuietly(fos); } JOptionPane.showMessageDialog(frame, res.getString("GenerateCsrAction.CsrGenerationSuccessful.message"), res.getString("GenerateCsrAction.GenerateCsr.Title"), JOptionPane.INFORMATION_MESSAGE); }
From source file:client.ui.UploadFileWindow.java
private void confirmButtonActionPerformed(ActionEvent evt) {//GEN-FIRST:event_confirmButtonActionPerformed String filePath = pathField.getText(); String filename = filenameField.getText(); if (filename.equals("")) { JOptionPane.showMessageDialog(this, "??", "", JOptionPane.WARNING_MESSAGE); return;//from w w w . ja v a 2 s . c om } if (filePath.equals("")) { JOptionPane.showMessageDialog(this, "", "", JOptionPane.WARNING_MESSAGE); return; } confirmFlag = true; this.setVisible(false); }