List of usage examples for javax.swing JOptionPane INFORMATION_MESSAGE
int INFORMATION_MESSAGE
To view the source code for javax.swing JOptionPane INFORMATION_MESSAGE.
Click Source Link
From source file:Interfaz.rubiktimer.java
public void cerrar() { try {/*w ww . j ava2s .co m*/ this.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent w) { int valor = JOptionPane.showConfirmDialog(null, "Esta Seguro de cerrar la aplicacion?\nNota: Asegurese de haber guardado los tiempos obtenidos ", "Cerrar Rubik Cube Timer", JOptionPane.OK_CANCEL_OPTION); if (valor == JOptionPane.OK_OPTION) { JOptionPane.showMessageDialog(null, "Gracias por usar Rubik Cube Timer", "Gracias", JOptionPane.INFORMATION_MESSAGE); System.exit(0); } else if (valor == JOptionPane.CANCEL_OPTION) { System.out.println("Cnacelar Operacion de cerrar"); } } }); this.setVisible(true); } catch (Exception e) { e.printStackTrace(); } }
From source file:edu.ku.brc.specify.Specify.java
/** * /*from www .j a v a 2s . com*/ */ private void startupContinuing() // needs to be called on the UI Thread { // Adjust Default Swing UI Default Resources (Color, Fonts, etc) per Platform UIHelper.adjustUIDefaults(); setupDefaultFonts(); if (!UIRegistry.doesAppversionsMatch()) { System.exit(0); } // Attachment related helpers Thumbnailer thumb = Thumbnailer.getInstance(); File thumbnailDir = null; try { thumbnailDir = XMLHelper.getConfigDir("thumbnail_generators.xml"); //$NON-NLS-1$ thumb.registerThumbnailers(thumbnailDir); } catch (Exception e1) { throw new RuntimeException("Couldn't find thumbnailer xml [" //$NON-NLS-1$ + (thumbnailDir != null ? thumbnailDir.getAbsolutePath() : "") + "]"); //$NON-NLS-1$ //$NON-NLS-2$ } thumb.setQuality(.5f); thumb.setMaxSize(256, 256); // Load Local Prefs AppPreferences localPrefs = AppPreferences.getLocalPrefs(); //localPrefs.setDirPath(UIRegistry.getAppDataDir()); //localPrefs.load(); moved to end for not-null constraint /*String derbyPath = localPrefs.get("javadb.location", null); if (StringUtils.isNotEmpty(derbyPath)) { UIRegistry.setJavaDBDir(derbyPath); log.debug("JavaDB Path: "+UIRegistry.getJavaDBPath()); }*/ String userSplashIconPath = AppPreferences.getLocalPrefs().get("specify.bg.image", null); if (userSplashIconPath != null) { SystemPrefs.changeSplashImage(); } AttachmentUtils.setThumbnailer(thumb); DefaultClassActionHandler defClassActionHandler = DefaultClassActionHandler.getInstance(); ActionListener attachmentDisplayer = AttachmentUtils.getAttachmentDisplayer(); Class<?>[] attachmentClasses = { Attachment.class, AccessionAttachment.class, AgentAttachment.class, BorrowAttachment.class, CollectingEventAttachment.class, CollectionObjectAttachment.class, ConservDescriptionAttachment.class, ConservEventAttachment.class, DNASequenceAttachment.class, DNASequencingRunAttachment.class, FieldNotebookAttachment.class, FieldNotebookPageAttachment.class, FieldNotebookPageSetAttachment.class, GiftAttachment.class, LoanAttachment.class, LocalityAttachment.class, PermitAttachment.class, PreparationAttachment.class, ReferenceWorkAttachment.class, RepositoryAgreementAttachment.class, StorageAttachment.class, TaxonAttachment.class, TreatmentEventAttachment.class, }; for (Class<?> cls : attachmentClasses) { defClassActionHandler.registerActionHandler(cls, attachmentDisplayer); } UsageTracker.incrUsageCount("RunCount"); //$NON-NLS-1$ //UIHelper.attachUnhandledException(); FileCache.setDefaultPath(UIRegistry.getAppDataDir() + File.separator + "cache"); //$NON-NLS-1$ cacheManager.registerCache(UIRegistry.getLongTermFileCache()); cacheManager.registerCache(UIRegistry.getShortTermFileCache()); cacheManager.registerCache(UIRegistry.getFormsCache()); cacheManager.registerCache(JasperReportsCache.getInstance()); UIRegistry.register(UIRegistry.MAINPANE, this); // important to be done immediately specifyApp = this; // this code simply demonstrates the creation of a system tray icon for Sp6 // perhaps someday we may want to use this capability // SystemTray sysTray = SystemTray.getSystemTray(); // PopupMenu popup = new PopupMenu("Sp6"); // MenuItem exitItem = new MenuItem("Exit"); // exitItem.addActionListener(new ActionListener() // { // public void actionPerformed(ActionEvent ae) // { // doExit(); // } // }); // popup.add(exitItem); // TrayIcon sp6icon = new TrayIcon(IconManager.getIcon("Specify16").getImage(),"Sepcify 6",popup); // try // { // sysTray.add(sp6icon); // } // catch (AWTException e1) // { // // TODO Auto-generated catch block // e1.printStackTrace(); // } //log.info("Creating Database configuration "); //$NON-NLS-1$ if (!isWorkbenchOnly) { HibernateUtil.setListener("post-commit-update", //$NON-NLS-1$ new edu.ku.brc.specify.dbsupport.PostUpdateEventListener()); HibernateUtil.setListener("post-commit-insert", //$NON-NLS-1$ new edu.ku.brc.specify.dbsupport.PostInsertEventListener()); // SInce Update get called when deleting an object there is no need to register this class. // The update deletes because first it removes the Lucene document and then goes to add it back in, but since the // the record is deleted it doesn't get added. HibernateUtil.setListener("post-commit-delete", //$NON-NLS-1$ new edu.ku.brc.specify.dbsupport.PostDeleteEventListener()); //HibernateUtil.setListener("delete", new edu.ku.brc.specify.dbsupport.DeleteEventListener()); } adjustLocaleFromPrefs(); CommandDispatcher.register(BaseTask.APP_CMD_TYPE, this); CommandDispatcher.register(ERRMSG, this); DatabaseLoginPanel.MasterPasswordProviderIFace usrPwdProvider = new DatabaseLoginPanel.MasterPasswordProviderIFace() { @Override public boolean hasMasterUserAndPwdInfo(final String username, final String password, final String dbName) { if (StringUtils.isNotEmpty(username) && StringUtils.isNotEmpty(password)) { UserAndMasterPasswordMgr.getInstance().set(username, password, dbName); return UserAndMasterPasswordMgr.getInstance().hasMasterUsernameAndPassword(); } return false; } @Override public Pair<String, String> getUserNamePassword(final String username, final String password, final String dbName) { UserAndMasterPasswordMgr.getInstance().set(username, password, dbName); Pair<String, String> usrPwd = UserAndMasterPasswordMgr.getInstance().getUserNamePasswordForDB(); return usrPwd; } @Override public boolean editMasterInfo(final String username, final String databaseNameArg, final boolean askForCredentials) { return UserAndMasterPasswordMgr.getInstance().editMasterInfo(username, databaseNameArg, askForCredentials); } }; if (UIRegistry.isMobile()) { DBConnection.setShutdownUI(new DBConnection.ShutdownUIIFace() { CustomDialog processDlg; /* (non-Javadoc) * @see edu.ku.brc.dbsupport.DBConnection.ShutdownUIIFace#displayInitialDlg() */ @Override public void displayInitialDlg() { SwingUtilities.invokeLater(new Runnable() { @Override public void run() { UIRegistry.showLocalizedMsg(JOptionPane.INFORMATION_MESSAGE, "MOBILE_INFO", "MOBILE_INTRO"); } }); } /* (non-Javadoc) * @see edu.ku.brc.dbsupport.DBConnection.ShutdownUIIFace#displayFinalShutdownDlg() */ @Override public void displayFinalShutdownDlg() { processDlg.setVisible(false); UIRegistry.showLocalizedMsg(JOptionPane.INFORMATION_MESSAGE, "MOBILE_INFO", "MOBILE_FINI"); } /* (non-Javadoc) * @see edu.ku.brc.dbsupport.DBConnection.ShutdownUIIFace#displayShutdownMsgDlg() */ @Override public void displayShutdownMsgDlg() { JPanel panel = new JPanel(new BorderLayout()); panel.setBorder(BorderFactory.createEmptyBorder(14, 14, 14, 14)); panel.add(new JLabel(IconManager.getIcon(getLargeIconName()), SwingConstants.CENTER), BorderLayout.WEST); panel.add(UIHelper.createI18NLabel("MOBILE_SHUTTING_DOWN", SwingConstants.CENTER), BorderLayout.CENTER); processDlg = new CustomDialog((Frame) null, "Shutdown", false, CustomDialog.NONE_BTN, panel); processDlg.setAlwaysOnTop(true); UIHelper.centerAndShow(processDlg); } }); } /*long lastSaved = AppPreferences.getLocalPrefs().getLong("update_time", 0L); if (lastSaved > 0) { Date now = Calendar.getInstance().getTime(); double elapsedMinutes = (now.getTime() - lastSaved) / 60000.0; log.debug(elapsedMinutes); if (elapsedMinutes < 1.0) { AppPreferences.setBlockTimer(); UIRegistry.showError("You are currently logged in.\n Logging in twice will cause problems for your account."); System.exit(0); } }*/ UIRegistry.dumpPaths(); dbLoginPanel = UIHelper.doLogin(usrPwdProvider, true, false, false, this, getLargeIconName(), getTitle(), null, getOpaqueIconName(), "login"); // true means do auto login if it can, second bool means use dialog instead of frame localPrefs.load(); }
From source file:eu.ggnet.dwoss.redtape.document.DocumentUpdateView.java
private void addUnitAction(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_addUnitAction if (unitInputField.getText().isEmpty()) return;// ww w .j a v a 2s . com if (document.isClosed()) { JOptionPane.showMessageDialog(this, "Hinzufgen von Sopo Ware nicht erlaubt.", "Abgeschlossenes Dokument", JOptionPane.INFORMATION_MESSAGE); return; } for (String sopo : unitInputField.getText().trim().split("(\\s*,\\s*|\\s+)")) { if (StringUtils.isBlank(sopo)) continue; try { controller.addPosition(document.getDossier().getId(), PositionType.UNIT, sopo, false); } catch (Exception ex) { DwOssCore.show(SwingUtilities.getWindowAncestor(this), ex); } } Platform.runLater(new Runnable() { @Override public void run() { positions.clear(); positions.addAll(document.getPositions().values()); } }); unitInputField.setText(""); }
From source file:model.settings.ReadSettings.java
private static boolean checkForUpdate(final View _view, final boolean _showNoUpdateMSG) { try {// ww w. j a v a 2s.c om // Create a URL for the desired page URL url = new URL("http://juliushuelsmann.github.io/paint/currentRelease"); // Read all the text returned by the server BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream())); String version = in.readLine(); in.close(); final String[] result = Version.getMilestonePercentageDone(version); if (result == null) { // error return false; } final String MS = result[0]; final String perc = result[1]; try { // parse information to integer. int new_milestone = Integer.parseInt(MS); int new_percentage = Integer.parseInt(perc); int crrnt_milestone = Integer.parseInt(Version.MILESTONE); int crrnt_percentage = Integer.parseInt(Version.PERCENTAGE_DONE); if (new_milestone > crrnt_milestone || (new_percentage > crrnt_percentage && new_milestone == crrnt_milestone)) { int d = JOptionPane.showConfirmDialog(_view, "A new version of paint has been found:\n" + "Used Version:\t" + "" + crrnt_milestone + "." + "" + crrnt_percentage + "\n" + "New Version:\t" + "" + new_milestone + "." + "" + new_percentage + "\n\n" + "Do you want to download it right now? \n" + "This operation will close paint and restart \n" + "the new version in about one minute.", "Update", JOptionPane.YES_NO_OPTION); return d == JOptionPane.YES_OPTION; } else { if (_showNoUpdateMSG) { JOptionPane.showMessageDialog(_view, "No updates found.", "Update", JOptionPane.INFORMATION_MESSAGE); } return false; } } catch (NumberFormatException _nex) { // received version number corrupted. final String err_msg = "Failed to check for updates, \n" + "the fetched version number is currupted.\n" + "This error is server-related and will be \n" + "fixed after it has been noticed by the \n" + "programmer ;)."; // report error via logger. model.settings.State.getLogger().severe(err_msg); // notify the user if this the message call isn't silent. if (_showNoUpdateMSG) { JOptionPane.showMessageDialog(_view, err_msg, "Update", JOptionPane.INFORMATION_MESSAGE); } return false; } } catch (Exception e) { // update page not found, probably due to network problems. final String err_msg = "Connection to update page failed. \n" + "Either you are not corrected to the internet or \n" + "the update page has been removed accidently. \n" + "If you are able to connect to any other web-page,\n" + "the error is server-related and will be \n" + "fixed after being noticed by the \n" + "programmer ;)."; // report error via logger. State.getLogger().warning(err_msg); // notify the user if this the message call isn't silent. if (_showNoUpdateMSG) { JOptionPane.showMessageDialog(_view, err_msg, "Update", JOptionPane.INFORMATION_MESSAGE); } return false; } }
From source file:com.zigabyte.stock.stratplot.StrategyPlotter.java
/** Load stock data specified in file field. If the data is from a serialized file, uses a ProgressMonitorInputStream to show progress. Once data is loaded, sets compareHistory to first symbol in COMPARE_INDEX_SYMBOLS found in data, and sets begin/end dates to the begin/end dates of this symbol, or of the first history in the data if no compare symbol was found. Shows a dialog when either completed or an error occurs. **///from w ww. j a v a 2 s .c om protected void loadFile() { try { // get file String filePath = this.fileField.getText().trim(); if (filePath.length() == 0) throw new IllegalArgumentException("Empty file"); File file = new File(filePath); // choose parser StockMarketHistoryFactory parser; { String fileFormat = (String) this.fileFormatCombo.getSelectedItem(); if ("Metastock".equals(fileFormat)) parser = new MetastockParser(true); else if ("Serialized".equals(fileFormat)) parser = new SerializedStockFilesParser(false); else if ("SerializedGZ".equals(fileFormat)) parser = new SerializedStockFilesParser(true); else throw new IllegalArgumentException("Unrecognized file format: " + fileFormat); } // load data using parser EventQueue.invokeLater(new Runnable() { public void run() { runButton.setEnabled(false); viewDataButton.setEnabled(false); } }); this.histories = null; // allow gc this.loadedHistoriesFile = null; if (!(parser instanceof SerializedStockFilesParser)) { this.histories = parser.loadHistory(file); } else { // use ProgressMonitorInputStream SerializedStockFilesParser serializedParser = (SerializedStockFilesParser) parser; InputStream in = new FileInputStream(file); ProgressMonitorInputStream pmIn = new ProgressMonitorInputStream(this, file.getName(), in); this.histories = serializedParser.loadHistory(pmIn); pmIn.close(); } this.loadedHistoriesFile = file; if (histories.size() > 0) { // initialize compareSymbol String compareIndexSymbol = ""; for (String spSymbol : COMPARE_INDEX_SYMBOLS) { if (histories.get(spSymbol) != null) { compareIndexSymbol = spSymbol; break; } } this.compareIndexSymbolField.setText(compareIndexSymbol); // initialize start/end fields StockHistory sampleHistory = (compareIndexSymbol.length() > 0 ? histories.get(compareIndexSymbol) : histories.get(0)); if (sampleHistory.size() > 0) { this.startDateField.setValue(sampleHistory.get(0).getDate()); this.endDateField.setValue(sampleHistory.get(sampleHistory.size() - 1).getDate()); } } // display completed dialog String msg = "Loaded " + this.histories.size() + " histories"; JOptionPane.showMessageDialog(this, msg, "Load complete", JOptionPane.INFORMATION_MESSAGE); } catch (FileNotFoundException e) { showErrorDialog(e, false); } catch (Exception e) { showErrorDialog(e); } finally { EventQueue.invokeLater(new Runnable() { public void run() { runButton.setEnabled(histories != null); viewDataButton.setEnabled(histories != null); loadFileButton.setCursor(null); // clear wait cursor } }); } }
From source file:userInteface.Patient.ManageVitalSignsJPanel.java
private void createChart() { DefaultCategoryDataset vitalSignDataset = new DefaultCategoryDataset(); int selectedRow = viewPatientsJTable.getSelectedRow(); Person person = (Person) viewPatientsJTable.getValueAt(selectedRow, 0); Patient patient = person.getPatient(); if (patient == null) { JOptionPane.showMessageDialog(this, "Patient not created, Please create Patient first.", "Error", JOptionPane.ERROR_MESSAGE); return;//from ww w . j a va 2s . com } ArrayList<VitalSign> vitalSignList = patient.getVitalSignHistory().getHistory(); /*At least 2 vital sign records needed to show chart */ if (vitalSignList.isEmpty() || vitalSignList.size() == 1) { JOptionPane.showMessageDialog(this, "No vital signs or only one vital sign found. At least 2 vital sign records needed to show chart!", "Warning", JOptionPane.INFORMATION_MESSAGE); return; } for (VitalSign vitalSign : vitalSignList) { vitalSignDataset.addValue(vitalSign.getRespiratoryRate(), "RR", vitalSign.getTimestamp()); vitalSignDataset.addValue(vitalSign.getHeartRate(), "HR", vitalSign.getTimestamp()); vitalSignDataset.addValue(vitalSign.getBloodPressure(), "BP", vitalSign.getTimestamp()); vitalSignDataset.addValue(vitalSign.getWeight(), "WT", vitalSign.getTimestamp()); } JFreeChart vitalSignChart = ChartFactory.createBarChart3D("Vital Sign Chart", "Time Stamp", "Rate", vitalSignDataset, PlotOrientation.VERTICAL, true, false, false); vitalSignChart.setBackgroundPaint(Color.white); CategoryPlot vitalSignChartPlot = vitalSignChart.getCategoryPlot(); vitalSignChartPlot.setBackgroundPaint(Color.lightGray); CategoryAxis vitalSignDomainAxis = vitalSignChartPlot.getDomainAxis(); vitalSignDomainAxis .setCategoryLabelPositions(CategoryLabelPositions.createUpRotationLabelPositions(Math.PI / 6.0)); NumberAxis vitalSignRangeAxis = (NumberAxis) vitalSignChartPlot.getRangeAxis(); vitalSignRangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); ChartFrame chartFrame = new ChartFrame("Chart", vitalSignChart); chartFrame.setVisible(true); chartFrame.setSize(500, 500); }
From source file:jboost.visualization.HistogramFrame.java
private void toPDF() { File pdf = selectPDFFile();/*from w w w . jav a 2 s. co m*/ if (pdf != null) { JComponent toDraw = this.jSplitPane2; File[] tmpFiles = new File[infoParser.maxNumIter]; for (int i = 0; i < infoParser.maxNumIter; i++) { post("Printing " + infoParser.iterNoList[i] + "..."); jList1.setSelectedIndex(i); jList1.scrollRectToVisible(jList1.getCellBounds(i, i)); loadIteration(i); BufferedImage bimg = new BufferedImage(toDraw.getWidth(), toDraw.getHeight(), BufferedImage.TYPE_INT_RGB); Graphics2D g = bimg.createGraphics(); toDraw.paint(g); g.dispose(); // add leading zeros String file_idx = Integer.toString(i); while (file_idx.length() < 3) file_idx = "0" + file_idx; try { tmpFiles[i] = new File("scorevistmp" + file_idx + ".png"); javax.imageio.ImageIO.write(bimg, "png", tmpFiles[i]); } catch (Exception e) { e.printStackTrace(); } } // restore plots jList1.setSelectedIndex(iter); loadIteration(iter); boolean success = true; // call convert to make pdf try { Process p = Runtime.getRuntime().exec("convert scorevistmp*.png " + pdf.getAbsolutePath()); p.waitFor(); } catch (Exception e) { success = false; } if (!success) { System.out.println("'convert' is missing. You need to have ImageMagick installed."); System.out.println("PDF is not generated but you can find PNG files in the current directory."); } else { /* * for (int i=0;i<maxNumIter-1;i++) { tmpFiles[i].delete(); } */ if (infoParser.maxNumIter > 0) { tmpFiles[infoParser.maxNumIter - 1].renameTo(new File(pdf.getAbsolutePath() + ".png")); } JOptionPane.showMessageDialog(this, "PDF file is generated!", "Done", JOptionPane.INFORMATION_MESSAGE); } } }
From source file:com.mindcognition.mindraider.install.Installer.java
/** * Asynchronous repository backup ensuring dialog refreshing. *///ww w .ja v a 2 s . c o m public static void backupRepositoryAsync() { Thread thread = new Thread() { public void run() { String targetFile; if ((targetFile = backupRepository()) == null) { JOptionPane.showMessageDialog(MindRaider.mainJFrame, Messages.getString("Installer.UnableToBackupRepository"), Messages.getString("Installer.backupError"), JOptionPane.ERROR_MESSAGE); } else { JOptionPane.showMessageDialog(MindRaider.mainJFrame, Messages.getString("Installer.repositoryBackupStoredTo", targetFile), Messages.getString("Installer.backupResult"), JOptionPane.INFORMATION_MESSAGE); } } }; thread.setDaemon(true); thread.start(); }
From source file:de.bfs.radon.omsimulation.gui.OMPanelTesting.java
/** * Initialises the interface of the results panel. *//* ww w. j av a 2s. c om*/ protected void initialize() { setLayout(null); isSimulated = false; lblExportChartTo = new JLabel("Export chart to ..."); lblExportChartTo.setBounds(436, 479, 144, 14); lblExportChartTo.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 11)); lblExportChartTo.setVisible(false); add(lblExportChartTo); btnCsv = new JButton("CSV"); btnCsv.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { JFileChooser fileDialog = new JFileChooser(); fileDialog.setFileFilter(new FileNameExtensionFilter("*.csv", "csv")); fileDialog.showSaveDialog(getParent()); final File file = fileDialog.getSelectedFile(); if (file != null) { String csv; String[] tmpFileName = file.getAbsolutePath().split("\\."); if (tmpFileName[tmpFileName.length - 1].equals("csv")) { csv = ""; } else { csv = ".csv"; } String csvPath = file.getAbsolutePath() + csv; double[] selectedValues; OMRoom[] rooms = new OMRoom[7]; rooms[0] = (OMRoom) comboBoxRoom1.getSelectedItem(); rooms[1] = (OMRoom) comboBoxRoom2.getSelectedItem(); rooms[2] = (OMRoom) comboBoxRoom3.getSelectedItem(); rooms[3] = (OMRoom) comboBoxRoom4.getSelectedItem(); rooms[4] = (OMRoom) comboBoxRoom5.getSelectedItem(); rooms[5] = (OMRoom) comboBoxRoom6.getSelectedItem(); rooms[6] = (OMRoom) comboBoxRoom7.getSelectedItem(); int start = sliderStartTime.getValue(); final int day = 24; File csvFile = new File(csvPath); try { OMCampaign campaign; if (isResult) { campaign = getResultCampaign(); } else { campaign = new OMCampaign(start, rooms, 0); } FileWriter logWriter = new FileWriter(csvFile); BufferedWriter csvOutput = new BufferedWriter(logWriter); csvOutput.write("\"ID\";\"Room\";\"Radon\""); csvOutput.newLine(); selectedValues = campaign.getValueChain(); int x = 0; for (int i = start; i < start + day; i++) { csvOutput.write("\"" + i + "\";\"" + rooms[0].getId() + "\";\"" + (int) selectedValues[x] + "\""); csvOutput.newLine(); x++; } start = start + day; for (int i = start; i < start + day; i++) { csvOutput.write("\"" + i + "\";\"" + rooms[1].getId() + "\";\"" + (int) selectedValues[x] + "\""); csvOutput.newLine(); x++; } start = start + day; for (int i = start; i < start + day; i++) { csvOutput.write("\"" + i + "\";\"" + rooms[2].getId() + "\";\"" + (int) selectedValues[x] + "\""); csvOutput.newLine(); x++; } start = start + day; for (int i = start; i < start + day; i++) { csvOutput.write("\"" + i + "\";\"" + rooms[3].getId() + "\";\"" + (int) selectedValues[x] + "\""); csvOutput.newLine(); x++; } start = start + day; for (int i = start; i < start + day; i++) { csvOutput.write("\"" + i + "\";\"" + rooms[4].getId() + "\";\"" + (int) selectedValues[x] + "\""); csvOutput.newLine(); x++; } start = start + day; for (int i = start; i < start + day; i++) { csvOutput.write("\"" + i + "\";\"" + rooms[5].getId() + "\";\"" + (int) selectedValues[x] + "\""); csvOutput.newLine(); x++; } start = start + day; for (int i = start; i < start + day; i++) { csvOutput.write("\"" + i + "\";\"" + rooms[6].getId() + "\";\"" + (int) selectedValues[x] + "\""); csvOutput.newLine(); x++; } JOptionPane.showMessageDialog(null, "CSV saved successfully!\n" + csvPath, "Success", JOptionPane.INFORMATION_MESSAGE); csvOutput.close(); } catch (IOException ioe) { JOptionPane.showMessageDialog(null, "Failed to write CSV. Please check permissions!\n" + ioe.getMessage(), "Failed", JOptionPane.ERROR_MESSAGE); ioe.printStackTrace(); } } else { JOptionPane.showMessageDialog(null, "Failed to write CSV. Please check the file path!", "Failed", JOptionPane.ERROR_MESSAGE); } } }); btnCsv.setBounds(590, 475, 70, 23); btnCsv.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 11)); btnCsv.setVisible(false); add(btnCsv); btnPdf = new JButton("PDF"); btnPdf.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { JFileChooser fileDialog = new JFileChooser(); fileDialog.setFileFilter(new FileNameExtensionFilter("*.pdf", "pdf")); fileDialog.showSaveDialog(getParent()); final File file = fileDialog.getSelectedFile(); if (file != null) { String pdf; String[] tmpFileName = file.getAbsolutePath().split("\\."); if (tmpFileName[tmpFileName.length - 1].equals("pdf")) { pdf = ""; } else { pdf = ".pdf"; } String pdfPath = file.getAbsolutePath() + pdf; OMRoom[] rooms = new OMRoom[7]; rooms[0] = (OMRoom) comboBoxRoom1.getSelectedItem(); rooms[1] = (OMRoom) comboBoxRoom2.getSelectedItem(); rooms[2] = (OMRoom) comboBoxRoom3.getSelectedItem(); rooms[3] = (OMRoom) comboBoxRoom4.getSelectedItem(); rooms[4] = (OMRoom) comboBoxRoom5.getSelectedItem(); rooms[5] = (OMRoom) comboBoxRoom6.getSelectedItem(); rooms[6] = (OMRoom) comboBoxRoom7.getSelectedItem(); int start = sliderStartTime.getValue(); OMCampaign campaign; try { if (isResult) { campaign = getResultCampaign(); } else { campaign = new OMCampaign(start, rooms, 0); } JFreeChart chart = OMCharts.createCampaignChart(campaign, false); String title = "Campaign: " + rooms[0].getId() + rooms[1].getId() + rooms[2].getId() + rooms[3].getId() + rooms[4].getId() + rooms[5].getId() + rooms[6].getId() + ", Start: " + start; int height = (int) PageSize.A4.getWidth(); int width = (int) PageSize.A4.getHeight(); try { OMExports.exportPdf(pdfPath, chart, width, height, new DefaultFontMapper(), title); JOptionPane.showMessageDialog(null, "PDF saved successfully!\n" + pdfPath, "Success", JOptionPane.INFORMATION_MESSAGE); } catch (IOException ioe) { JOptionPane.showMessageDialog(null, "Failed to write PDF. Please check permissions!\n" + ioe.getMessage(), "Failed", JOptionPane.ERROR_MESSAGE); ioe.printStackTrace(); } } catch (IOException ioe) { JOptionPane.showMessageDialog(null, "Failed to create chart!\n" + ioe.getMessage(), "Failed", JOptionPane.ERROR_MESSAGE); ioe.printStackTrace(); } } else { JOptionPane.showMessageDialog(null, "Failed to write PDF. Please check the file path!", "Failed", JOptionPane.ERROR_MESSAGE); } } }); btnPdf.setBounds(670, 475, 70, 23); btnPdf.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 11)); btnPdf.setVisible(false); add(btnPdf); lblSelectProject = new JLabel("Select Project"); lblSelectProject.setBounds(10, 65, 132, 14); lblSelectProject.setFont(new Font("SansSerif", Font.PLAIN, 11)); add(lblSelectProject); lblSelectRooms = new JLabel("Select Rooms"); lblSelectRooms.setBounds(10, 94, 132, 14); lblSelectRooms.setFont(new Font("SansSerif", Font.PLAIN, 11)); add(lblSelectRooms); lblStartTime = new JLabel("Start Time"); lblStartTime.setBounds(10, 123, 132, 14); lblStartTime.setFont(new Font("SansSerif", Font.PLAIN, 11)); add(lblStartTime); lblWarning = new JLabel("Select 6 rooms and 1 cellar!"); lblWarning.setForeground(Color.RED); lblWarning.setBounds(565, 123, 175, 14); lblWarning.setFont(new Font("SansSerif", Font.PLAIN, 11)); lblWarning.setVisible(false); add(lblWarning); sliderStartTime = new JSlider(); sliderStartTime.setMaximum(0); sliderStartTime.setBounds(152, 119, 285, 24); sliderStartTime.setFont(new Font("SansSerif", Font.PLAIN, 11)); add(sliderStartTime); spnrStartTime = new JSpinner(); spnrStartTime.setModel(new SpinnerNumberModel(0, 0, 0, 1)); spnrStartTime.setBounds(447, 120, 108, 22); spnrStartTime.setFont(new Font("SansSerif", Font.PLAIN, 11)); add(spnrStartTime); btnRefresh = new JButton("Load"); btnRefresh.setBounds(616, 61, 124, 23); btnRefresh.setFont(new Font("SansSerif", Font.PLAIN, 11)); add(btnRefresh); btnMaximize = new JButton("Fullscreen"); btnMaximize.setBounds(10, 475, 124, 23); btnMaximize.setFont(new Font("SansSerif", Font.PLAIN, 11)); add(btnMaximize); panelCampaign = new JPanel(); panelCampaign.setBounds(10, 150, 730, 315); panelCampaign.setFont(new Font("SansSerif", Font.PLAIN, 11)); add(panelCampaign); progressBar = new JProgressBar(); progressBar.setBounds(10, 475, 730, 23); progressBar.setFont(new Font("SansSerif", Font.PLAIN, 11)); progressBar.setVisible(false); add(progressBar); lblOpenOmbfile = new JLabel("Open OMB-File"); lblOpenOmbfile.setFont(new Font("SansSerif", Font.PLAIN, 11)); lblOpenOmbfile.setBounds(10, 36, 132, 14); add(lblOpenOmbfile); lblHelp = new JLabel("Select an OMB-Object file to manually simulate virtual campaigns."); lblHelp.setForeground(Color.GRAY); lblHelp.setFont(new Font("SansSerif", Font.PLAIN, 11)); lblHelp.setBounds(10, 10, 730, 14); add(lblHelp); txtOmbFile = new JTextField(); txtOmbFile.setFont(new Font("SansSerif", Font.PLAIN, 11)); txtOmbFile.setColumns(10); txtOmbFile.setBounds(152, 33, 454, 20); add(txtOmbFile); btnBrowse = new JButton("Browse"); btnBrowse.setFont(new Font("SansSerif", Font.PLAIN, 11)); btnBrowse.setBounds(616, 32, 124, 23); add(btnBrowse); comboBoxRoom1 = new JComboBox<OMRoom>(); comboBoxRoom1.setBounds(152, 90, 75, 22); comboBoxRoom1.setFont(new Font("SansSerif", Font.PLAIN, 11)); add(comboBoxRoom1); comboBoxRoom2 = new JComboBox<OMRoom>(); comboBoxRoom2.setBounds(237, 90, 75, 22); comboBoxRoom2.setFont(new Font("SansSerif", Font.PLAIN, 11)); add(comboBoxRoom2); comboBoxRoom3 = new JComboBox<OMRoom>(); comboBoxRoom3.setBounds(323, 90, 75, 22); comboBoxRoom3.setFont(new Font("SansSerif", Font.PLAIN, 11)); add(comboBoxRoom3); comboBoxRoom4 = new JComboBox<OMRoom>(); comboBoxRoom4.setBounds(408, 90, 75, 22); comboBoxRoom4.setFont(new Font("SansSerif", Font.PLAIN, 11)); add(comboBoxRoom4); comboBoxRoom5 = new JComboBox<OMRoom>(); comboBoxRoom5.setBounds(494, 90, 75, 22); comboBoxRoom5.setFont(new Font("SansSerif", Font.PLAIN, 11)); add(comboBoxRoom5); comboBoxRoom6 = new JComboBox<OMRoom>(); comboBoxRoom6.setBounds(579, 90, 75, 22); comboBoxRoom6.setFont(new Font("SansSerif", Font.PLAIN, 11)); add(comboBoxRoom6); comboBoxRoom7 = new JComboBox<OMRoom>(); comboBoxRoom7.setBounds(665, 90, 75, 22); comboBoxRoom7.setFont(new Font("SansSerif", Font.PLAIN, 11)); add(comboBoxRoom7); comboBoxProjects = new JComboBox<OMBuilding>(); comboBoxProjects.setBounds(152, 61, 454, 22); comboBoxProjects.setFont(new Font("SansSerif", Font.PLAIN, 11)); add(comboBoxProjects); comboBoxRoom1.addActionListener(this); comboBoxRoom1.addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { validateCampaign(); } }); comboBoxRoom2.addActionListener(this); comboBoxRoom2.addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { validateCampaign(); } }); comboBoxRoom3.addActionListener(this); comboBoxRoom3.addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { validateCampaign(); } }); comboBoxRoom4.addActionListener(this); comboBoxRoom4.addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { validateCampaign(); } }); comboBoxRoom5.addActionListener(this); comboBoxRoom5.addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { validateCampaign(); } }); comboBoxRoom6.addActionListener(this); comboBoxRoom6.addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { validateCampaign(); } }); comboBoxRoom7.addActionListener(this); comboBoxRoom7.addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { validateCampaign(); } }); sliderStartTime.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { if (comboBoxProjects.isEnabled() || isResult) { if (comboBoxProjects.getSelectedItem() != null) { spnrStartTime.setValue((int) sliderStartTime.getValue()); updateChart(); } } } }); spnrStartTime.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent arg0) { if (comboBoxProjects.isEnabled() || isResult) { if (comboBoxProjects.getSelectedItem() != null) { sliderStartTime.setValue((Integer) spnrStartTime.getValue()); updateChart(); } } } }); btnRefresh.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { if (txtOmbFile.getText() != null && !txtOmbFile.getText().equals("") && !txtOmbFile.getText().equals(" ")) { txtOmbFile.setBackground(Color.WHITE); String ombPath = txtOmbFile.getText(); String omb; String[] tmpFileName = ombPath.split("\\."); if (tmpFileName[tmpFileName.length - 1].equals("omb")) { omb = ""; } else { omb = ".omb"; } txtOmbFile.setText(ombPath + omb); setOmbFile(ombPath + omb); File ombFile = new File(ombPath + omb); if (ombFile.exists()) { txtOmbFile.setBackground(Color.WHITE); btnRefresh.setEnabled(false); comboBoxProjects.setEnabled(false); setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); progressBar.setVisible(true); btnPdf.setVisible(false); btnCsv.setVisible(false); btnMaximize.setVisible(false); lblExportChartTo.setVisible(false); progressBar.setIndeterminate(true); progressBar.setStringPainted(true); refreshTask = new Refresh(); refreshTask.execute(); } else { txtOmbFile.setBackground(new Color(255, 222, 222, 128)); JOptionPane.showMessageDialog(null, "OMB-file not found, please check the file path!", "Error", JOptionPane.ERROR_MESSAGE); } } else { txtOmbFile.setBackground(new Color(255, 222, 222, 128)); JOptionPane.showMessageDialog(null, "Please select an OMB-file!", "Warning", JOptionPane.WARNING_MESSAGE); } } }); btnMaximize.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { try { OMRoom[] rooms = new OMRoom[7]; rooms[0] = (OMRoom) comboBoxRoom1.getSelectedItem(); rooms[1] = (OMRoom) comboBoxRoom2.getSelectedItem(); rooms[2] = (OMRoom) comboBoxRoom3.getSelectedItem(); rooms[3] = (OMRoom) comboBoxRoom4.getSelectedItem(); rooms[4] = (OMRoom) comboBoxRoom5.getSelectedItem(); rooms[5] = (OMRoom) comboBoxRoom6.getSelectedItem(); rooms[6] = (OMRoom) comboBoxRoom7.getSelectedItem(); int start = sliderStartTime.getValue(); String title = "Campaign: " + rooms[0].getId() + rooms[1].getId() + rooms[2].getId() + rooms[3].getId() + rooms[4].getId() + rooms[5].getId() + rooms[6].getId() + ", Start: " + start; OMCampaign campaign; if (isResult) { campaign = getResultCampaign(); } else { campaign = new OMCampaign(start, rooms, 0); } JPanel campaignChart = createCampaignPanel(campaign, false, true); JFrame chartFrame = new JFrame(); chartFrame.getContentPane().add(campaignChart); chartFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); Dimension dim = Toolkit.getDefaultToolkit().getScreenSize(); chartFrame.setBounds(0, 0, (int) dim.getWidth(), (int) dim.getHeight()); chartFrame.setTitle(title); chartFrame.setResizable(true); chartFrame.setExtendedState(JFrame.MAXIMIZED_BOTH); chartFrame.setVisible(true); } catch (IOException ioe) { ioe.printStackTrace(); } } }); txtOmbFile.addFocusListener(new FocusAdapter() { @Override public void focusLost(FocusEvent arg0) { setOmbFile(txtOmbFile.getText()); } }); btnBrowse.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { JFileChooser fileDialog = new JFileChooser(); fileDialog.setFileFilter(new FileNameExtensionFilter("*.omb", "omb")); fileDialog.showOpenDialog(getParent()); final File file = fileDialog.getSelectedFile(); if (file != null) { String omb; String[] tmpFileName = file.getAbsolutePath().split("\\."); if (tmpFileName[tmpFileName.length - 1].equals("omb")) { omb = ""; } else { omb = ".omb"; } txtOmbFile.setText(file.getAbsolutePath() + omb); setOmbFile(file.getAbsolutePath() + omb); } } }); }
From source file:jboost.visualization.HistogramFrame.java
private void dumpExamples() { File txt = selectDumpFile();/*w w w .j ava2 s . c om*/ if (txt != null) { rawData.setOutputFilename(txt.getAbsolutePath()); rawData.printScores(infoParser.iterNoList[iter], lowerMarkerScore, upperMarkerScore); JOptionPane.showMessageDialog(this, "Operation completed successfully!", "Done", JOptionPane.INFORMATION_MESSAGE); } }