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:sistemacontrole.LeituraEscritaCanais.java
LeituraEscritaCanais(LoginWindow loginWindow, MainWindow mainWindow) { //setar views this.loginWindow = loginWindow; this.mainWindow = mainWindow; this.plantaSimulacao = new Simulacao(); //checar se foi login offline this.isOffline = this.loginWindow.isOffline(); //cria a conexo com a planta caso no seja offline if (!this.isOffline) { try {// w w w. j ava 2s . c om this.quanserClient = new QuanserClient(this.loginWindow.GetIP(), this.loginWindow.GetPorta()); } catch (QuanserClientException ex) { JOptionPane.showMessageDialog(this.loginWindow, "Erro ao se conectar a planta!", "Erro!", JOptionPane.ERROR_MESSAGE); System.out.println("Erro ao se conectar a planta!"); } } else { JOptionPane.showMessageDialog(this.loginWindow, "Planta no conectada! \nModo de simulao ativado.", "Ateno!", JOptionPane.WARNING_MESSAGE); this.mainWindow.setTitle(this.mainWindow.getTitle() + " (Offline)"); } //varivel de tempo global para grfico this.tempoGlobal = 0; //inicializar curvas dos grficos this.sinal_calculado = new XYSeries("Saida 0 - Calculado"); this.sinal_tratado = new XYSeries("Saida 0 - Tratada"); this.sinal_entrada = new XYSeries[7]; this.valor_P = new XYSeries("Parametro P"); this.valor_I = new XYSeries("Parametro I"); this.valor_D = new XYSeries("Parametro D"); this.erro_PID = new XYSeries("Erro calculado"); this.setPointCurva = new XYSeries("Set Point"); for (int i = 0; i < 7; ++i) { this.sinal_entrada[i] = new XYSeries("Canal " + i); } //iniciar tempo global tempoInicial = System.nanoTime(); //inicializao de threads this.relogio = new Thread(new atualizarTempoGlobal());//inicializar contador de tempo new Thread(new atualizarGraficos()).start();//inicializar atualizao dos grficos new Thread(new getCanaisValores()).start();//inicializar leitura dos canais //objetos de sincronizao de leitura e escrita de canal leituraEscrita = new leituraEscritaSync(); }
From source file:cl.almejo.vsim.gui.actions.preferences.ColorPreferences.java
public ColorPreferences(Component parent) { _parent = parent;/*from w w w . j a va 2 s .co m*/ setBorder(new EmptyBorder(10, 10, 10, 10)); setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); JPanel pickers = new JPanel(); pickers.setLayout(new GridLayout(10, 2)); pickers.add(new Label(Messages.t("preferences.color.scheme.current.label"))); _comboBox = createSchemeCombobox(); pickers.add(_comboBox); addColorChooser(pickers, "gates"); addColorChooser(pickers, "background"); addColorChooser(pickers, "bus-on"); addColorChooser(pickers, "ground"); addColorChooser(pickers, "off"); addColorChooser(pickers, "wires-on"); addColorChooser(pickers, "signal"); addColorChooser(pickers, "grid"); addColorChooser(pickers, "label"); add(pickers); JPanel buttons = new JPanel(); JButton button = new JButton(Messages.t("preferences.color.scheme.save.label")); buttons.add(button); button.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { try { FileUtils.writeStringToFile(new File("colors.json"), ColorScheme.save()); } catch (IOException e1) { e1.printStackTrace(); } } }); button = new JButton(Messages.t("preferences.color.scheme.new.label")); button.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { String themeName = JOptionPane.showInputDialog(Messages.t("color.scheme.dialog.new.title"), ""); if (themeName != null) { while (ColorScheme.exists(themeName)) { JOptionPane.showMessageDialog(_parent, Messages.t("color.scheme.dialog.already.exists.error"), "Error", JOptionPane.ERROR_MESSAGE); themeName = JOptionPane.showInputDialog(this, themeName); } ColorScheme.add(themeName); _comboBox.addItem(themeName); _comboBox.setSelectedItem(themeName); } } }); buttons.add(button); add(buttons); }
From source file:com.edduarte.protbox.core.Constants.java
public static BufferedImage getAsset(String resourceFileName) { BufferedImage result = cachedAssets.get(resourceFileName); if (result == null) { try {/* w w w . j a v a 2s . c o m*/ InputStream stream = Protbox.class.getResourceAsStream(resourceFileName); result = ImageIO.read(stream); cachedAssets.put(resourceFileName, result); } catch (IOException | IllegalArgumentException ex) { ex.printStackTrace(); JOptionPane.showMessageDialog(null, "Asset file " + resourceFileName + " not detected or corrupted!\n" + "Please reinstall the application.", "Nonexistent or corrupted asset file", JOptionPane.ERROR_MESSAGE); System.exit(1); } } return result; }
From source file:com.k42b3.sacmis.ExecutorAbstract.java
public void run() { try {//from w ww . j a v a2 s . co m // clear text this.textArea.setText(""); CommandLine commandLine = CommandLine.parse(this.getExecutable() + " " + this.cmd); ExecuteWatchdog watchdog = new ExecuteWatchdog(ExecuteWatchdog.INFINITE_TIMEOUT); // create executor DefaultExecutor executor = new DefaultExecutor(); executor.setStreamHandler(new PumpStreamHandler(new TextAreaOutputStream(textArea))); executor.setWatchdog(watchdog); executor.execute(commandLine); } catch (FoundNoExecutableException e) { JOptionPane.showMessageDialog(null, e.getMessage(), "Information", JOptionPane.ERROR_MESSAGE); } catch (IOException e) { logger.error(e.getMessage(), e); } }
From source file:edu.harvard.i2b2.query.ui.QueryRequestClient.java
public static String sendQueryRequestREST(String XMLstr) { try {//from ww w .j a va 2 s . c o m 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(200000)); options.setProperty(HTTPConstants.CONNECTION_TIMEOUT, new Integer(200000)); ServiceClient sender = new ServiceClient(); sender.setOptions(options); OMElement result = sender.sendReceive(payload); // System.out.println(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:Models.UserModel.java
public User LogIn(String email, String password) { try {/*from ww w. ja v a 2 s . c o m*/ String auth = HMAC_SHA256(email, password); FileInputStream file = new FileInputStream("src/Data/users.dat"); User user; try (ObjectInputStream inStream = new ObjectInputStream(file)) { users = (ArrayList<User>) inStream.readObject(); for (int i = 0; i < users.size(); ++i) { if (users.get(i).getEmail().equals(email) && users.get(i).getAuth().equals(auth)) { inStream.close(); return users.get(i); } } inStream.close(); return null; } } catch (IOException | ClassNotFoundException e) { System.out.println(e.getMessage()); JOptionPane.showMessageDialog(null, "Error read file", "ERROR", 2); return null; } }
From source file:de.bfs.radon.omsimulation.gui.data.OMExports.java
/** * //from w ww . j a v a2 s. c om * Method to export charts as PDF files using the defined path. * * @param path * The filename and absolute path. * @param chart * The JFreeChart object. * @param width * The width of the PDF file. * @param height * The height of the PDF file. * @param mapper * The font mapper for the PDF file. * @param title * The title of the PDF file. * @throws IOException * If writing a PDF file fails. */ @SuppressWarnings("deprecation") public static void exportPdf(String path, JFreeChart chart, int width, int height, FontMapper mapper, String title) throws IOException { File file = new File(path); FileOutputStream pdfStream = new FileOutputStream(file); BufferedOutputStream pdfOutput = new BufferedOutputStream(pdfStream); Rectangle pagesize = new Rectangle(width, height); Document document = new Document(); document.setPageSize(pagesize); document.setMargins(50, 50, 50, 50); document.addAuthor("OMSimulationTool"); document.addSubject(title); try { PdfWriter pdfWriter = PdfWriter.getInstance(document, pdfOutput); document.open(); PdfContentByte contentByte = pdfWriter.getDirectContent(); PdfTemplate template = contentByte.createTemplate(width, height); Graphics2D g2D = template.createGraphics(width, height, mapper); Double r2D = new Rectangle2D.Double(0, 0, width, height); chart.draw(g2D, r2D); g2D.dispose(); contentByte.addTemplate(template, 0, 0); } catch (DocumentException de) { JOptionPane.showMessageDialog(null, "Failed to write PDF document.\n" + de.getMessage(), "Failed", JOptionPane.ERROR_MESSAGE); de.printStackTrace(); } document.close(); }
From source file:ExecDemoNS.java
/** Start the help, in its own Thread. */ public void runProg() { new Thread() { public void run() { try { // Get the URL for the Help File URL helpURL = this.getClass().getClassLoader().getResource(HELPFILE); // Start Netscape from the Java Application. pStack.push(Runtime.getRuntime().exec(program + " " + helpURL)); } catch (Exception ex) { JOptionPane.showMessageDialog(ExecDemoNS.this, "Error" + ex, "Error", JOptionPane.ERROR_MESSAGE); }/* www . j a va 2s . c om*/ } }.start(); }
From source file:EnrollFingerprint.Enroll.java
/** * Creates new form Enroll// w ww. j av a 2 s.co m */ public Enroll() { initComponents(); updateStatus(); // Event listener actived when fingerprint template is ready this.addPropertyChangeListener(TEMPLATE_PROPERTY, new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { btnSave.setEnabled(template != null); if (evt.getNewValue() == evt.getOldValue()) { return; } if (template != null) { JOptionPane.showMessageDialog(Enroll.this, "La huella capturada esta lista para ser guardada.", "Captura y Registro de huellas", JOptionPane.INFORMATION_MESSAGE); } } }); }
From source file:net.rptools.maptool.client.AppSetup.java
public static void installLibrary(final String libraryName, final File root) throws IOException { // Add as a resource root AppPreferences.addAssetRoot(root);/* ww w.ja v a 2s . co m*/ if (MapTool.getFrame() != null) { MapTool.getFrame().addAssetRoot(root); // License File licenseFile = new File(root, "License.txt"); if (!licenseFile.exists()) { licenseFile = new File(root, "license.txt"); } if (licenseFile.exists()) { final File licenseFileFinal = licenseFile; EventQueue.invokeLater(new Runnable() { public void run() { try { JTextPane pane = new JTextPane(); pane.setPage(licenseFileFinal.toURI().toURL()); JOptionPane.showMessageDialog(MapTool.getFrame(), pane, "License for " + libraryName, JOptionPane.INFORMATION_MESSAGE); } catch (MalformedURLException e) { log.error("Could not load license file: " + licenseFileFinal, e); } catch (IOException e) { log.error("Could not load license file: " + licenseFileFinal, e); } } }); } } new SwingWorker<Object, Object>() { @Override protected Object doInBackground() throws Exception { AssetManager.searchForImageReferences(root, AppConstants.IMAGE_FILE_FILTER); return null; } }.execute(); }