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:com.t3.client.TabletopTool.java
/** * Displays a dialog box with a predefined title and type, and a message * crafted by calling {@link #generateMessage(String, Throwable)} and * passing it the two parameters. Also logs an entry using the * {@link Logger#warn(Object, Throwable)} method. * <p>/* w w w . j a v a2 s . c o m*/ * The title is the property key * <code>"msg.title.messageDialogWarning"</code>, and the dialog type is * <code>JOptionPane.WARNING_MESSAGE</code>. * * @param msgKey * the key to use when calling {@link I18N#getText(String)} * @param t * the exception to be processed */ public static void showWarning(String msgKey, Throwable t) { String msg = generateMessage(msgKey, t); log.warn(msgKey, t); showMessage(msg, "msg.title.messageDialogWarning", JOptionPane.WARNING_MESSAGE); }
From source file:userinterface.EnvironmentRole.PollutionCheckJPanel.java
private void btnCheckReportActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCheckReportActionPerformed int selectedRow = tableCarOwners.getSelectedRow(); if (selectedRow < 0) { JOptionPane.showMessageDialog(null, "Please select a row from the table first", "Warning", JOptionPane.WARNING_MESSAGE); return;//w ww . j ava2s. com } else { WorkRequest workRequest = (WorkRequest) tableCarOwners.getValueAt(selectedRow, 3); UserAccount userAccount = workRequest.getSender(); XYSeries series = new XYSeries("XYGraph"); int i = 0; for (Fine fine : environmentOrganization.getFineHistory().getFineIncurredhistory()) { if (userAccount == fine.getUserAccount()) { series.add(fine.getFineIncurred(), i); //fine.getDate().getTime() i++; } } XYSeriesCollection dataset = new XYSeriesCollection(); dataset.addSeries(series); JFrame frame = new JFrame("Charts"); frame.setSize(600, 400); // frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setVisible(true); JFreeChart chart = ChartFactory.createXYLineChart("Test Chart", "Time", "Fine", dataset, PlotOrientation.VERTICAL, true, true, false); ChartPanel cp = new ChartPanel(chart); frame.getContentPane().add(cp); } }
From source file:com.clough.android.adbv.view.UpdateTableDialog.java
private int validateRowSelection() { int[] selectedRows = resultTable.getSelectedRows(); int rowCount = selectedRows.length; if (rowCount > 0) { return selectedRows[rowCount - 1]; } else {//from w ww .j a v a 2s.c o m JOptionPane.showMessageDialog(null, "Select a row to remove/update", "Row removing/updating", JOptionPane.WARNING_MESSAGE); return -1; } }
From source file:net.chaosserver.timelord.swingui.Timelord.java
/** * Returns if the system is already running based on the creation of a lock * file that is deleted when the JVM exits and creates a new instance of the * lockfile for this JVM. If the lockfile is detected it presents a dialog * giving an option for the end user to overwrite the lock file. * * @return indicates another instance of timelord is already running *///from w w w. j a va 2 s. co m public boolean isAlreadyRunning() { boolean alreadyRunning = false; File homeDirectory = new File(System.getProperty("user.home")); File lockFile = new File(homeDirectory, "Timelord.lockfile"); if (lockFile.exists()) { String startAnyway = "Start Anyway"; String dontStart = "Cancel Start"; Object[] options = { dontStart, startAnyway }; int result = JOptionPane.showOptionDialog(null, "A lockfile for an instance of timelord " + "has been found. If you are already " + "running timelord, click \"" + dontStart + "\" and use the running program.", "Timelord Already Running", JOptionPane.DEFAULT_OPTION, JOptionPane.WARNING_MESSAGE, null, options, dontStart); if (result == 0) { alreadyRunning = true; } } if (!alreadyRunning) { try { lockFile.createNewFile(); lockFile.deleteOnExit(); } catch (IOException e) { throw new RuntimeException(e); } } return alreadyRunning; }
From source file:bio.gcat.gui.BDATool.java
public boolean saveFile(File file) { try (Writer writer = new OutputStreamWriter(new FileOutputStream(file), CHARSET)) { writeTo(writer, bdaPanel.getBinaryDichotomicAlgorithms()); return true; } catch (IOException e) { JOptionPane.showMessageDialog(this, "Could not save file:\n" + e.getMessage(), "Save File", JOptionPane.WARNING_MESSAGE); return false; }/*from w w w.j a v a 2 s .c om*/ }
From source file:userInterface.HospitalDoctor.HospitalDoctorWorkAreaJPanel.java
private void sendAlertBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_sendAlertBtnActionPerformed int selectedRow = vitalSignjTable.getSelectedRow(); if (selectedRow < 0) { JOptionPane.showMessageDialog(null, "Please select a row", "WARNING", JOptionPane.WARNING_MESSAGE); return;//from www .ja v a2s.c o m } else { VitalSign vs = (VitalSign) vitalSignjTable.getValueAt(selectedRow, 1); if (vs.getAlertStatus().equals("Requested doc")) { vs.setAlertStatus("Doc Reviewed"); HospitalWorkRequest request = (HospitalWorkRequest) vitalSignjTable.getValueAt(selectedRow, 0); Date responseDate = new Date(); request.setReceiver(userAccount); String alert = messageTxt.getText(); request.setAlert(alert); request.setRequestDate(responseDate); String severity = severityTxt.getText(); request.setSeverity(severity); request.setStatus("checked by doctor"); populateAlertsTable(); JOptionPane.showMessageDialog(null, "Doctor's Response Sent", "MESSAGE", JOptionPane.INFORMATION_MESSAGE); } else { JOptionPane.showMessageDialog(null, "Doctor has already reviewed", "MESSAGE", JOptionPane.INFORMATION_MESSAGE); } } }
From source file:io.github.jeddict.jpa.modeler.properties.annotation.AnnotationPanel.java
private boolean validateField() { if (this.annotation_EditorPane.getText().trim() .length() <= 0 /*|| Pattern.compile("[^\\w-]").matcher(this.id_TextField.getText().trim()).find()*/) { JOptionPane.showMessageDialog(this, "Annotation can't be empty", "Invalid Value", javax.swing.JOptionPane.WARNING_MESSAGE); return false; } else if (this.annotation_EditorPane.getText().trim().charAt(0) != '@') { JOptionPane.showMessageDialog(this, "Invalid Annotation type (missing @)", "Invalid Value", javax.swing.JOptionPane.WARNING_MESSAGE); return false; }/* w w w .ja v a2 s . co m*/ return true; }
From source file:com.raceup.fsae.test.TesterGui.java
/** * Shows dialog with info about unsuccessful test submission *//*from ww w . j a v a 2 s . c om*/ private void showUnSuccessfulTestSubmissionDialog() { totalTestTimer.start(); // re-start total timer String message = test.toString(); message += "\nDon't worry, be happy: this box will automatically " + "close after " + Integer.toString(SECONDS_WAIT_BETWEEN_SUBMISSIONS) + " seconds of your " + "submission.\nEnjoy."; JOptionPane opt = new JOptionPane(message, JOptionPane.WARNING_MESSAGE, JOptionPane.DEFAULT_OPTION, null, new Object[] {}); // no buttons final JDialog dlg = opt.createDialog("Error"); new Thread(() -> { try { Thread.sleep(SECONDS_WAIT_BETWEEN_SUBMISSIONS * 1000); dlg.dispose(); } catch (Throwable t) { System.err.println(t.toString()); } }).start(); dlg.setVisible(true); }
From source file:edu.ku.brc.af.ui.forms.SubViewBtn.java
/** * //from w w w .j a va 2 s . co m */ protected void showForm() { //boolean isParentNew = parentObj instanceof FormDataObjIFace ? ((FormDataObjIFace)parentObj).getId() == null : false; boolean isNewObject = MultiView.isOptionOn(options, MultiView.IS_NEW_OBJECT); boolean isEdit = MultiView.isOptionOn(options, MultiView.IS_EDITTING) || isNewObject; String closeBtnTitle = isEdit ? getResourceString("DONE") : getResourceString("CLOSE"); ViewBasedDisplayDialog dlg = new ViewBasedDisplayDialog((Frame) UIRegistry.getTopWindow(), subviewDef.getViewSetName(), subviewDef.getViewName(), null, // What is this argument??? frameTitle, closeBtnTitle, view.getClassName(), cellName, // idFieldName isEdit | isNewObject, false, cellName, mvParent, options | MultiView.HIDE_SAVE_BTN | MultiView.DONT_ADD_ALL_ALTVIEWS | MultiView.USE_ONLY_CREATION_MODE, CustomDialog.CANCEL_BTN | (StringUtils.isNotEmpty(helpContext) ? CustomDialog.HELP_BTN : 0)) { /* (non-Javadoc) * @see edu.ku.brc.ui.db.ViewBasedDisplayDialog#cancelButtonPressed() */ @Override protected void cancelButtonPressed() { multiView.aboutToShutdown(); FormViewObj fvo = multiView.getCurrentViewAsFormViewObj(); if (fvo != null) { FormValidator validator = multiView.getCurrentValidator(); if (validator != null && validator.getState() != UIValidatable.ErrorType.Valid) { boolean isNew = fvo.isNewlyCreatedDataObj(); String msgKey = isNew ? "MV_INCOMPLETE_DATA_NEW" : "MV_INCOMPLETE_DATA"; String btnKey = isNew ? "MV_REMOVE_ITEM" : "MV_DISCARD_ITEM"; Object[] optionLabels = { getResourceString(btnKey), getResourceString("CANCEL") }; int rv = JOptionPane.showOptionDialog(UIRegistry.getMostRecentWindow(), getResourceString(msgKey), getResourceString("MV_INCOMPLETE_DATA_TITLE"), JOptionPane.DEFAULT_OPTION, JOptionPane.WARNING_MESSAGE, null, optionLabels, optionLabels[0]); if (rv == JOptionPane.NO_OPTION) { return; } } } super.cancelButtonPressed(); } }; dlg.setHelpContext("SUBVIEW_FORM_HELP"); dlg.setCancelLabel(closeBtnTitle); frame = dlg; multiView = frame.getMultiView(); // Only get the data from the parent the first time. if (parentObj != null && dataObj == null) { DataProviderSessionIFace sessionLocal = null; try { DataObjectGettable getter = DataObjectGettableFactory.get(parentObj.getClass().getName(), FormHelper.DATA_OBJ_GETTER); sessionLocal = parentObj.getId() != null ? DataProviderFactory.getInstance().createSession() : null; // rods - 07/22/08 - Apparently Merge just doesn't work the way it seems it should // so instead we will just go get the parent again. if (parentObj.getId() != null) { parentObj = (FormDataObjIFace) sessionLocal.get(parentObj.getDataClass(), parentObj.getId()); } Object[] objs = UIHelper.getFieldValues(subviewDef, parentObj, getter); if (objs == null) { try { Class<?> cls = Class.forName(view.getClassName()); if (FormDataObjIFace.class.isAssignableFrom(cls)) { dataObj = cls.newInstance(); ((FormDataObjIFace) dataObj).initialize(); parentObj.addReference((FormDataObjIFace) dataObj, subviewDef.getName()); } } catch (Exception ex) { ex.printStackTrace(); edu.ku.brc.af.core.UsageTracker.incrHandledUsageCount(); edu.ku.brc.exceptions.ExceptionTracker.getInstance().capture(SubViewBtn.class, ex); } } else { dataObj = objs[0]; } multiView.setParentDataObj(parentObj); multiView.setData(dataObj); CommandDispatcher.dispatch(new CommandAction("Data_Entry", "SHOW_SUBVIEW", new Pair<Object, Object>(parentObj, dataObj))); } catch (Exception ex) { ex.printStackTrace(); edu.ku.brc.af.core.UsageTracker.incrHandledUsageCount(); edu.ku.brc.exceptions.ExceptionTracker.getInstance().capture(SubViewBtn.class, ex); } finally { if (sessionLocal != null) { sessionLocal.close(); } } } else { multiView.setParentDataObj(parentObj); DataProviderSessionIFace sessionLocal = null; try { sessionLocal = DataProviderFactory.getInstance().createSession(); multiView.setSession(sessionLocal); if (dataObj instanceof Set<?>) { for (Object obj : ((Set<?>) dataObj)) { if (obj instanceof FormDataObjIFace && ((FormDataObjIFace) obj).getId() != null) { sessionLocal.attach(obj); } } } else if (dataObj instanceof FormDataObjIFace && ((FormDataObjIFace) dataObj).getId() != null) { sessionLocal.attach(dataObj); } multiView.setData(dataObj); multiView.setSession(null); } catch (Exception ex) { ex.printStackTrace(); } finally { sessionLocal.close(); } } multiView.setClassToCreate(classToCreate); FormValidator formVal = null; if (multiView.getCurrentViewAsFormViewObj() != null) { formVal = multiView.getCurrentViewAsFormViewObj().getValidator(); if (formVal != null) { formVal.setEnabled(true); multiView.addCurrentValidator(); if (multiView.getCurrentViewAsFormViewObj() != null) { final ResultSetController rsc = multiView.getCurrentViewAsFormViewObj().getRsController(); if (rsc != null && rsc.getNewRecBtn() != null) { rsc.getNewRecBtn().setEnabled(true); /*if (rsc.getLength() == 0) { SwingUtilities.invokeLater(new Runnable() { @Override public void run() { //rsc.getNewRecBtn().doClick(); } }); }*/ } } } } dlg.createUI(); frame.getCancelBtn().setEnabled(true); frame.showDisplay(true); if (formVal != null) { multiView.removeCurrentValidator(); } FormViewObj fvo = null; if (multiView != null) { if (frame.isEditMode()) { frame.getMultiView().getDataFromUI(); FormViewObj.traverseToGetDataFromForms(frame.getMultiView()); updateBtnText(); mvParent.getCurrentValidator().validateRoot(); } } else { } CommandDispatcher.dispatch(new CommandAction("Data_Entry", "CLOSE_SUBVIEW", new Triple<Object, Object, Object>(fvo, parentObj, dataObj))); frame.dispose(); frame = null; }
From source file:be.ugent.maf.cellmissy.gui.controller.analysis.doseresponse.generic.GenericDoseResponseController.java
/** * Initialize main view/* ww w. jav a 2s . co m*/ */ @Override protected void initMainView() { genericDRParentPanel = new GenericDRParentPanel(); dRPanel = new DRPanel(); //buttons disabled at start genericDRParentPanel.getCancelButton().setEnabled(false); genericDRParentPanel.getNextButton().setEnabled(false); getCardLayout().first(genericDRParentPanel.getContentPanel()); onCardSwitch(); //create a ButtonGroup for the radioButtons used for analysis ButtonGroup mainDRRadioButtonGroup = new ButtonGroup(); //adding buttons to a ButtonGroup automatically deselect one when another one gets selected mainDRRadioButtonGroup.add(dRPanel.getInputDRButton()); mainDRRadioButtonGroup.add(dRPanel.getInitialPlotDRButton()); mainDRRadioButtonGroup.add(dRPanel.getNormalizedPlotDRButton()); mainDRRadioButtonGroup.add(dRPanel.getResultsDRButton()); //select as default first button dRPanel.getInputDRButton().setSelected(true); //init dataTable dataTable = new JTable(); JScrollPane scrollPane = new JScrollPane(dataTable); //the table will take all the viewport height available dataTable.setFillsViewportHeight(true); scrollPane.getViewport().setBackground(Color.white); dataTable.getTableHeader().setReorderingAllowed(false); //row and column selection must be false //dataTable.setColumnSelectionAllowed(false); //dataTable.setRowSelectionAllowed(false); dRPanel.getDatatableDRPanel().add(scrollPane, BorderLayout.CENTER); setLogTransform(true); /** * Action listeners for uppermost panel. */ //this button is ONLY used when going from the loading to the analysis genericDRParentPanel.getNextButton().addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { genericDRParentPanel.getNextButton().setEnabled(false); genericDRParentPanel.getCancelButton().setEnabled(true); //save any metadata that was provided manually loadGenericDRDataController.setManualMetaData(importedDRDataHolder); //switch between child panels getCardLayout().next(genericDRParentPanel.getContentPanel()); onCardSwitch(); } }); genericDRParentPanel.getCancelButton().addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { // warn the user and reset everything Object[] options = { "Yes", "No" }; int showOptionDialog = JOptionPane.showOptionDialog(null, "Current analysis won't be saved. Continue?", "", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE, null, options, options[1]); if (showOptionDialog == 0) { // reset everything resetOnCancel(); } } }); /** * Action listeners for shared panel. When button is selected, switch * view to corresponding subview */ dRPanel.getInputDRButton().addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { //switch shared table view updateModelInTable(dRInputController.getTableModel()); updateTableInfoMessage("This table contains all conditions and their respective responses"); /** * for (int columnIndex = 0; columnIndex < * dataTable.getColumnCount(); columnIndex++) { * GuiUtils.packColumn(dataTable, columnIndex); } */ dataTable.getTableHeader().setDefaultRenderer(new TableHeaderRenderer(SwingConstants.LEFT)); //remove other panels dRInitialController.getInitialChartPanel().setChart(null); dRNormalizedController.getNormalizedChartPanel().setChart(null); dRResultsController.getDupeInitialChartPanel().setChart(null); dRResultsController.getDupeNormalizedChartPanel().setChart(null); dRPanel.getGraphicsDRParentPanel().removeAll(); dRPanel.getGraphicsDRParentPanel().revalidate(); dRPanel.getGraphicsDRParentPanel().repaint(); //add panel to view dRPanel.getGraphicsDRParentPanel().add(dRInputController.getdRInputPanel(), gridBagConstraints); } }); dRPanel.getInitialPlotDRButton().addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (dRAnalysisGroup != null) { if (isFirstFitting()) { initFirstFitting(); setFirstFitting(false); } //switch shared table view updateModelInTable(dRInitialController.getTableModel()); updateTableInfoMessage( "If you checked the box at the import screen, the doses have been log-transformed. Responses have not been changed"); /** * for (int columnIndex = 0; columnIndex < * dataTable.getColumnCount(); columnIndex++) { * GuiUtils.packColumn(dataTable, columnIndex); } */ dataTable.getTableHeader().setDefaultRenderer(new TableHeaderRenderer(SwingConstants.LEFT)); //remove other panels dRNormalizedController.getNormalizedChartPanel().setChart(null); dRResultsController.getDupeInitialChartPanel().setChart(null); dRResultsController.getDupeNormalizedChartPanel().setChart(null); dRPanel.getGraphicsDRParentPanel().removeAll(); dRPanel.getGraphicsDRParentPanel().revalidate(); dRPanel.getGraphicsDRParentPanel().repaint(); dRPanel.getGraphicsDRParentPanel().add(dRInitialController.getDRInitialPlotPanel(), gridBagConstraints); //Plot fitted data in dose-response curve, along with R annotation plotDoseResponse(dRInitialController.getInitialChartPanel(), dRInitialController.getDRInitialPlotPanel().getDoseResponseChartParentPanel(), getDataToFit(false), getdRAnalysisGroup(), false); } } }); dRPanel.getNormalizedPlotDRButton().addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (dRAnalysisGroup != null) { //in case user skips "initial" subview and goes straight to normalization if (isFirstFitting()) { initFirstFitting(); setFirstFitting(false); } //switch shared table view updateModelInTable(dRNormalizedController.getTableModel()); updateTableInfoMessage( "Potentially log-transformed doses with their normalized responses per replicate"); /** * for (int columnIndex = 0; columnIndex < * dataTable.getColumnCount(); columnIndex++) { * GuiUtils.packColumn(dataTable, columnIndex); } */ dataTable.getTableHeader().setDefaultRenderer(new TableHeaderRenderer(SwingConstants.LEFT)); //remove other panels dRInitialController.getInitialChartPanel().setChart(null); dRResultsController.getDupeInitialChartPanel().setChart(null); dRResultsController.getDupeNormalizedChartPanel().setChart(null); dRPanel.getGraphicsDRParentPanel().removeAll(); dRPanel.getGraphicsDRParentPanel().revalidate(); dRPanel.getGraphicsDRParentPanel().repaint(); dRPanel.getGraphicsDRParentPanel().add(dRNormalizedController.getDRNormalizedPlotPanel(), gridBagConstraints); //Plot fitted data in dose-response curve, along with R annotation plotDoseResponse(dRNormalizedController.getNormalizedChartPanel(), dRNormalizedController.getDRNormalizedPlotPanel().getDoseResponseChartParentPanel(), getDataToFit(true), getdRAnalysisGroup(), true); } } }); dRPanel.getResultsDRButton().addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (dRAnalysisGroup != null) { //switch shared table view: create and set new table model with most recent statistical values // (these values get recalculated after each new fitting) dRResultsController.setTableModel(dRResultsController.reCreateTableModel(dRAnalysisGroup)); updateModelInTable(dRResultsController.getTableModel()); updateTableInfoMessage( "Statistical values from the curve fit of the initial and normalized data."); //remove other panels dRInitialController.getInitialChartPanel().setChart(null); dRNormalizedController.getNormalizedChartPanel().setChart(null); dRPanel.getGraphicsDRParentPanel().removeAll(); dRPanel.getGraphicsDRParentPanel().revalidate(); dRPanel.getGraphicsDRParentPanel().repaint(); dRPanel.getGraphicsDRParentPanel().add(dRResultsController.getdRResultsPanel(), gridBagConstraints); //plot curves dRResultsController.plotCharts(); } } }); //add views to parent panels cellMissyController.getCellMissyFrame().getDoseResponseAnalysisParentPanel().add(genericDRParentPanel, gridBagConstraints); genericDRParentPanel.getDataLoadingPanel().add(loadGenericDRDataController.getDataLoadingPanel(), gridBagConstraints); genericDRParentPanel.getDoseResponseParentPanel().add(dRPanel, gridBagConstraints); }