List of usage examples for javax.swing JOptionPane OK_OPTION
int OK_OPTION
To view the source code for javax.swing JOptionPane OK_OPTION.
Click Source Link
From source file:co.com.soinsoftware.hotelero.view.JFRoomPayment.java
private void jbtSaveActionPerformed(java.awt.event.ActionEvent evt) {// GEN-FIRST:event_jbtSaveActionPerformed if (this.validateDataForSave()) { final int confirmation = ViewUtils.showConfirmDialog(this, ViewUtils.MSG_SAVE_QUESTION, ViewUtils.TITLE_SAVED);/* w ww .j a v a2 s.com*/ if (confirmation == JOptionPane.OK_OPTION) { final Invoice invoice = this.getInvoiceSelected(); final InvoiceStatus invoiceStatus = this.getInvoiceStatusSelected(); final Date finalDate = this.jdcFinalDate.getDate(); final long total = this.getTotalValue(); invoice.setUpdated(new Date()); invoice.setRoomStatus(roomStatusEnabled); invoice.setInvoiceStatus(invoiceStatus); invoice.setFinalDate(finalDate); invoice.setValue(total); this.invoiceController.save(invoice); ViewUtils.showMessage(this, ViewUtils.MSG_SAVED, ViewUtils.TITLE_SAVED, JOptionPane.INFORMATION_MESSAGE); this.jfRoom.refreshRoomData(); this.refresh(); } } }
From source file:pi.bestdeal.gui.InterfacePrincipale.java
private void Update_ButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_Update_ButtonActionPerformed DealDAO dealdao = DealDAO.getInstance(); Modifier_Ajouter modaj = new Modifier_Ajouter(); Deal abc = new Deal(); Deal deal = new Deal(); int idd = (int) jTable1.getModel().getValueAt(jTable1.getSelectedRow(), 0); List<Deal> listdeal = dealdao .displayDealById((int) jTable1.getModel().getValueAt(jTable1.getSelectedRow(), 0)); for (Deal a : listdeal) { abc = a;/*from w w w .ja va 2 s . c om*/ } modaj.txtTitre.setText(abc.getTitreDeal_Deal()); modaj.txtDesc.setText(abc.getDescDeal_Deal()); modaj.txtPrix.setText(abc.getPrixDeal_Deal().toString()); modaj.txtValidation.setText(String.valueOf(abc.getNbrAchatValidation())); modaj.jdateDebut.setDate(abc.getDateDebutDeal_Deal()); modaj.jdateFin.setDate(abc.getDateFinDeal_Deal()); if (abc.isStatutDeal() == true) { modaj.jCheckBox1.setSelected(true); } else { modaj.jCheckBox1.setSelected(false); } if (abc.getEtatDeal_Deal().toString().equals("Pass")) { modaj.jComboBox1.setSelectedIndex(0); } if (abc.getEtatDeal_Deal().toString().equals("Courant")) { modaj.jComboBox1.setSelectedIndex(1); } if (abc.getEtatDeal_Deal().toString().equals("Comming")) { modaj.jComboBox1.setSelectedIndex(2); } if (abc.getCategorie_Deal().toString().equalsIgnoreCase("High-Tech")) { modaj.ComboCategorie.setSelectedIndex(0); } if (abc.getCategorie_Deal().toString().equalsIgnoreCase("Bricolage")) { modaj.ComboCategorie.setSelectedIndex(1); } if (abc.getCategorie_Deal().toString().equalsIgnoreCase("Bijouterie")) { modaj.ComboCategorie.setSelectedIndex(2); } if (abc.getCategorie_Deal().toString().equalsIgnoreCase("Vacances&Sorties")) { modaj.ComboCategorie.setSelectedIndex(3); } if (abc.getCategorie_Deal().toString().equalsIgnoreCase("Beaut")) { modaj.ComboCategorie.setSelectedIndex(4); } if (abc.getCategorie_Deal().toString().equalsIgnoreCase("Accessoires&Vtements")) { modaj.ComboCategorie.setSelectedIndex(5); } if (abc.getCategorie_Deal().toString().equalsIgnoreCase("Divers")) { modaj.ComboCategorie.setSelectedIndex(6); } abc.setEtatDeal_Deal(modaj.jComboBox1.getSelectedItem().toString()); int result = JOptionPane.showConfirmDialog(null, modaj, "Test", JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE); if (result == JOptionPane.OK_OPTION) { deal.setTitreDeal_Deal(modaj.txtTitre.getText()); Vendeur vendeur = new Vendeur(); VendeurDAO daov = VendeurDAO.getInstance(); for (Vendeur a : daov.displayvendeurByNom(modaj.jList1.getSelectedValue().toString())) { vendeur = a; } deal.setIdDeal_Deal(idd); deal.setDescDeal_Deal(modaj.txtDesc.getText()); deal.setPrixDeal_Deal(Double.valueOf(modaj.txtPrix.getText())); deal.setNbrAchatValidation(Integer.valueOf(modaj.txtValidation.getText())); deal.setNbrAchatActuelDeal_Deal(0); deal.setNbrAffichage_Deal(0); deal.setEtatDeal_Deal(modaj.jComboBox1.getSelectedItem().toString()); java.util.Date d1 = modaj.jdateDebut.getCalendar().getTime(); java.sql.Date sqlDate = new java.sql.Date(d1.getTime()); java.util.Date d2 = modaj.jdateFin.getCalendar().getTime(); java.sql.Date sqlDate2 = new java.sql.Date(d2.getTime()); deal.setDateDebutDeal_Deal(sqlDate); deal.setDateFinDeal_Deal(sqlDate2); deal.setCategorie_Deal(modaj.ComboCategorie.getSelectedItem().toString()); deal.setIdVendeur_Deal(vendeur.getIdVendeur()); if (modaj.jCheckBox1.isSelected()) { deal.setStatutDeal_Deal(true); } else { deal.setStatutDeal_Deal(false); } int f = dealdao.updateDeal(deal); if (f == 1) { JOptionPane.showMessageDialog(null, "Deal modifi"); DealTableModel mymodel = new DealTableModel(list.displayDeal()); jTable1.setModel(mymodel); jTable1.removeColumn(jTable1.getColumn("ID")); jTable1.removeColumn(jTable1.getColumn("Description")); jTable1.removeColumn(jTable1.getColumn("Achat Actuel")); jTable1.removeColumn(jTable1.getColumn("Etat")); jTable1.removeColumn(jTable1.getColumn("Statut")); jTable1.removeColumn(jTable1.getColumn("Nombre d'Affichage")); jTable1.removeColumn(jTable1.getColumn("Vendeur")); jTable1.getColumnModel().setColumnMargin(20); if (!list.displayDeal().isEmpty()) { jTable1.setRowSelectionInterval(0, 0); } } } else { System.out.println("Cancelled"); } }
From source file:io.gameover.utilities.pixeleditor.Pixelizer.java
public void openFile() { JFileChooser fc = new JFileChooser(); int ret = fc.showOpenDialog(this); if (ret == JFileChooser.APPROVE_OPTION) { try {// ww w .jav a 2 s.c o m BufferedImage image = ImageIO.read(fc.getSelectedFile()); if (image.getHeight() > Frame.NB_PIXELS || image.getWidth() % Frame.NB_PIXELS != 0 || image.getHeight() != Frame.NB_PIXELS) { int retOption = JOptionPane.showConfirmDialog(this, "Image seems not a pixel image (height > " + Frame.NB_PIXELS + "px or length not a multiple of " + Frame.NB_PIXELS + "). Would you like to convert it to pixel?"); if (retOption == JOptionPane.OK_OPTION) { convertToPixelImage(image); } } else { openImage(image); } refreshCurrentColors(); savedStates.clear(); currentStateIndex = 0; clearSelection(); refresh(); } catch (IOException ex) { ex.printStackTrace(); } } }
From source file:com.net2plan.gui.utils.viewEditTopolTables.specificTables.AdvancedJTable_demand.java
public static void createLinkDemandGUI(final NetworkElementType networkElementType, final IVisualizationCallback callback) { final NetPlan netPlan = callback.getDesign(); final JComboBox originNodeSelector = new WiderJComboBox(); final JComboBox destinationNodeSelector = new WiderJComboBox(); for (Node node : netPlan.getNodes()) { final String nodeName = node.getName(); String nodeLabel = "Node " + node.getIndex(); if (!nodeName.isEmpty()) nodeLabel += " (" + nodeName + ")"; originNodeSelector.addItem(StringLabeller.of(node.getId(), nodeLabel)); destinationNodeSelector.addItem(StringLabeller.of(node.getId(), nodeLabel)); }//from w ww .ja va 2 s . c o m ItemListener nodeListener = new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { long originNodeId = (long) ((StringLabeller) originNodeSelector.getSelectedItem()).getObject(); long destinationNodeId = (long) ((StringLabeller) destinationNodeSelector.getSelectedItem()) .getObject(); callback.putTransientColorInElementTopologyCanvas( Arrays.asList(netPlan.getNodeFromId(originNodeId)), Color.GREEN); callback.putTransientColorInElementTopologyCanvas( Arrays.asList(netPlan.getNodeFromId(destinationNodeId)), Color.CYAN); } }; originNodeSelector.addItemListener(nodeListener); destinationNodeSelector.addItemListener(nodeListener); originNodeSelector.setSelectedIndex(0); destinationNodeSelector.setSelectedIndex(1); JPanel pane = new JPanel(); pane.add(networkElementType == NetworkElementType.LINK ? new JLabel("Origin node: ") : new JLabel("Ingress node: ")); pane.add(originNodeSelector); pane.add(Box.createHorizontalStrut(15)); pane.add(networkElementType == NetworkElementType.LINK ? new JLabel("Destination node: ") : new JLabel("Egress node: ")); pane.add(destinationNodeSelector); while (true) { int result = JOptionPane.showConfirmDialog(null, pane, "Please enter end nodes for the new " + networkElementType, JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE); if (result != JOptionPane.OK_OPTION) return; try { long originNodeId = (long) ((StringLabeller) originNodeSelector.getSelectedItem()).getObject(); long destinationNodeId = (long) ((StringLabeller) destinationNodeSelector.getSelectedItem()) .getObject(); Node originNode = netPlan.getNodeFromId(originNodeId); Node destinationNode = netPlan.getNodeFromId(destinationNodeId); if (netPlan.getNodeFromId(originNodeId) == null) throw new Net2PlanException("Node of id: " + originNodeId + " does not exist"); if (netPlan.getNodeFromId(destinationNodeId) == null) throw new Net2PlanException("Node of id: " + destinationNodeId + " does not exist"); if (networkElementType == NetworkElementType.LINK) { final Link e = netPlan.addLink(originNode, destinationNode, 0, 0, 200000, null); callback.getVisualizationState() .recomputeCanvasTopologyBecauseOfLinkOrNodeAdditionsOrRemovals(); callback.updateVisualizationAfterChanges(Collections.singleton(NetworkElementType.LINK)); callback.getVisualizationState().pickLink(e); callback.updateVisualizationAfterPick(); callback.getUndoRedoNavigationManager().addNetPlanChange(); } else { final Demand d = netPlan.addDemand(originNode, destinationNode, 0, null); callback.updateVisualizationAfterChanges(Collections.singleton(NetworkElementType.DEMAND)); callback.getVisualizationState().pickDemand(d); callback.updateVisualizationAfterPick(); callback.getUndoRedoNavigationManager().addNetPlanChange(); } break; } catch (Throwable ex) { ErrorHandling.showErrorDialog(ex.getMessage(), "Error adding " + networkElementType); } } }
From source file:de.whiledo.iliasdownloader2.swing.service.MainController.java
protected void showAutoSyncSettings() { JCheckBox checkboxAutoSyncActive; JTextField fieldSyncInterval; JPanel panel = new JPanel(new BorderLayout()); {/*from w ww .jav a 2s . c o m*/ checkboxAutoSyncActive = new JCheckBox("Automatische Synchronisierung aktiv"); checkboxAutoSyncActive.setSelected(iliasProperties.isAutoSyncActive()); panel.add(checkboxAutoSyncActive, BorderLayout.NORTH); } { JPanel panel2 = new JPanel(new FlowLayout(FlowLayout.LEFT)); panel2.add(new JLabel("Intervall in Minuten:")); fieldSyncInterval = new JTextField(String.valueOf(iliasProperties.getAutoSyncIntervalInSeconds() / 60), 20); panel2.add(fieldSyncInterval); panel.add(panel2, BorderLayout.CENTER); } { panel.add(new JLabel( "<html>Sie knnen das Programm auch ohne GUI laufen lassen.<br>Weitere Informationen hierzu erhalten Sie, wenn Sie das Programm folgendermaen starten<br>java -jar <name>.jar help</html>"), BorderLayout.SOUTH); } if (JOptionPane.OK_OPTION == JOptionPane.showConfirmDialog(mainFrame, panel, "Automatische Synchronisierung einstellen", JOptionPane.OK_CANCEL_OPTION)) { iliasProperties.setAutoSyncActive(checkboxAutoSyncActive.isSelected()); iliasProperties.setAutoSyncIntervalInSeconds(Integer.parseInt(fieldSyncInterval.getText()) * 60); saveProperties(iliasProperties); startOrStopAutoSync(); } }
From source file:com.codejumble.opentube.Main.java
/** * Opens the settings dialog and processes the changes performed (if * necessary)/*from w w w . j ava 2 s . co m*/ * * @param evt Swing event */ private void settingsItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_settingsItemActionPerformed JTextField setting = new JTextField(configuredFolderForDownloadedMedia); Object[] settings = { "Downloads folder", setting }; int option = JOptionPane.showConfirmDialog(null, settings, "Settings", JOptionPane.OK_CANCEL_OPTION); if (option == JOptionPane.OK_OPTION) { configuration.setProperty("downloadFolder", setting.getText()); try { logger.info("Saving settings"); configuration.save(); } catch (ConfigurationException ex) { createErrorDialog(this, ex.getMessage(), "Fatal error"); } } }
From source file:org.apache.jmeter.visualizers.CreateReport.java
@Override public void actionPerformed(ActionEvent ev) { /*/* www .j a v a2 s. c o m*/ if(ev.equals(SAVEASCSV)) { saveAsCsv.setSelected(true); } else if (ev.equals(SAVEASPDF) { saveAsPdf.setSelected(true); } */ String action = ev.getActionCommand(); if (action.equals(BROWSE)) { JFileChooser j = new JFileChooser(); j.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); int returnVal = j.showOpenDialog(this); if (returnVal == JFileChooser.APPROVE_OPTION) { basepath.setText(j.getSelectedFile().getAbsolutePath()); BASEPATH = basepath.getText().trim(); JOptionPane.showMessageDialog(null, "alert", basepath.getText(), JOptionPane.OK_OPTION); } if (ev.getSource() == saveTable) { JFileChooser chooser = FileDialoger.promptToSaveFile("summary.csv");//$NON-NLS-1$ if (chooser == null) { return; } FileWriter writer = null; try { writer = new FileWriter(chooser.getSelectedFile()); CSVSaveService.saveCSVStats(model, writer, saveHeaders.isSelected()); } catch (FileNotFoundException e) { log.warn(e.getMessage()); } catch (IOException e) { log.warn(e.getMessage()); } finally { JOrphanUtils.closeQuietly(writer); } } } }
From source file:edu.ku.brc.specify.config.init.secwiz.DatabasePanel.java
/** * Check the engine and charset./* www .j a v a2 s . c o m*/ * @param props the props * @return true if it exists */ protected boolean checkEngineCharSet(final Properties props) { final String databaseName = props.getProperty(DBNAME); DBMSUserMgr mgr = null; try { String itUsername = props.getProperty(DBUSERNAME); String itPassword = props.getProperty(DBPWD); String hostName = props.getProperty(HOSTNAME); if (!DBConnection.getInstance().isEmbedded()) { mgr = DBMSUserMgr.getInstance(); if (mgr.connectToDBMS(itUsername, itPassword, hostName)) { if (!mgr.verifyEngineAndCharSet(databaseName)) { String errMsg = mgr.getErrorMsg(); if (errMsg != null) { Object[] options = { getResourceString("CLOSE") }; JOptionPane.showOptionDialog(getTopWindow(), errMsg, getResourceString("DEL_CUR_DB_TITLE"), JOptionPane.OK_OPTION, JOptionPane.QUESTION_MESSAGE, null, options, options[0]); } return false; } return true; } } else { return true; } } catch (Exception ex) { edu.ku.brc.af.core.UsageTracker.incrHandledUsageCount(); edu.ku.brc.exceptions.ExceptionTracker.getInstance().capture(SpecifyDBSecurityWizard.class, ex); } finally { if (mgr != null) { mgr.close(); } } return false; }
From source file:edu.ku.brc.specify.tools.ireportspecify.MainFrameSpecify.java
/** * @param repResName/* www. j a va2 s .c om*/ * @param tableId * @param spReport * @param appRes * * Allows editing of SpReport and SpAppResource properties for reports. */ protected static AppResAndProps getProps(final String repResName, final Integer tableId, final ReportSpecify spReport, final AppResourceIFace appRes) { String repType; if (appRes == null) { repType = "Report"; } else { String mime = appRes.getMimeType(); String reportType = appRes.getMetaDataMap().getProperty("reporttype", null); if (mime.equals(ReportsBaseTask.LABELS_MIME)) { repType = "Label"; } else if (mime.equals(ReportsBaseTask.SUBREPORTS_MIME)) { repType = "Subreport"; } else { if (reportType != null && reportType.equalsIgnoreCase("invoice")) { repType = "Invoice"; } else { repType = "Report"; } } } RepResourcePropsPanel propPanel = new RepResourcePropsPanel(repResName, repType, tableId == null, spReport); boolean goodProps = false; boolean overwrite = false; SpAppResource match = null; CustomDialog cd = new CustomDialog((Frame) UIRegistry.getTopWindow(), UIRegistry.getResourceString("REP_PROPS_DLG_TITLE"), true, propPanel); propPanel.setCanceller(cd.getCancelBtn()); while (!goodProps) { UIHelper.centerAndShow(cd); if (cd.isCancelled()) { return null; } String repName = propPanel.getNameTxt().getText().trim(); boolean isNameOK = repName.matches("[a-zA-Z0-9\\-. '`_]*"); if (StringUtils.isEmpty(repName)) { JOptionPane.showMessageDialog(UIRegistry.getTopWindow(), String.format(UIRegistry.getResourceString("REP_NAME_MUST_NOT_BE_BLANK"), propPanel.getNameTxt().getText())); } else if (!isNameOK) { Toolkit.getDefaultToolkit().beep(); JOptionPane.showMessageDialog(UIRegistry.getTopWindow(), UIRegistry.getResourceString("INVALID_CHARS_NAME")); } else { match = getRepResource(propPanel.getNameTxt().getText()); if (match != null) { if (appRes == null || !((SpAppResource) appRes).getId().equals(match.getId())) { int chc = JOptionPane.showConfirmDialog(UIRegistry.getTopWindow(), String.format( UIRegistry.getResourceString("REP_NAME_ALREADY_EXISTS_OVERWRITE_CONFIRM"), propPanel.getNameTxt().getText())); if (chc == JOptionPane.OK_OPTION) { goodProps = true; overwrite = true; } else if (chc != JOptionPane.NO_OPTION) { return null; } } else { goodProps = true; } } else { goodProps = true; } goodProps = goodProps && propPanel.validInputs(); } } if (goodProps /*just in case*/) { if (match != null && overwrite) { //user has chosen to overwrite an identically named report //XXX - Is it possible that another user created the matching report? //first close design frame for match if one exists. /* * Actually, never mind, too hard to do in this method. * Let the user deal with it. */ //delete match Integer matchRepId = null; DataProviderSessionIFace session = DataProviderFactory.getInstance().createSession(); try { SpReport matchRep = session.getData(SpReport.class, "appResource", match, DataProviderSessionIFace.CompareType.Equals); if (matchRep == null) { JOptionPane.showMessageDialog(null, String.format(UIRegistry.getResourceString("REP_UNABLE_TO_OVERWRITE"), match.getName()), UIRegistry.getResourceString("Error"), JOptionPane.ERROR_MESSAGE); return null; } matchRepId = matchRep.getId(); } finally { session.close(); session = null; } ReportsBaseTask.deleteReportAndResource(matchRepId, match.getId()); overwrittenReportId = matchRepId; } AppResourceIFace modifiedRes = null; if (appRes == null) { String dirName = ((RepResourcePropsPanel.ResDirItem) propPanel.getResDirCombo().getSelectedItem()) .getName(); SpAppResourceDir dir = getDirForResource(dirName); modifiedRes = ((SpecifyAppContextMgr) AppContextMgr.getInstance()).createAppResourceForDir(dir); } else { modifiedRes = appRes; String dirName = ((RepResourcePropsPanel.ResDirItem) propPanel.getResDirCombo().getSelectedItem()) .getName(); SpAppResourceDir dir = getDirForResource(dirName); ((SpAppResource) modifiedRes).setSpAppResourceDir(dir); } modifiedRes.setName(propPanel.getNameTxt().getText().trim()); modifiedRes.setDescription(propPanel.getNameTxt().getText().trim()); modifiedRes.setLevel(Short.valueOf(propPanel.getLevelTxt().getText())); propPanel.getResDirCombo().getSelectedItem(); String metaDataStr = "tableid=" + propPanel.getTableId() + ";"; if (propPanel.getTypeCombo().getSelectedIndex() == 2) { metaDataStr += "reporttype=Invoice;"; } else { metaDataStr += "reporttype=Report;"; } if (propPanel.getSubReportsTxt() != null && propPanel.getSubReportsTxt().getText() != null) { metaDataStr += "subreports=" + propPanel.getSubReportsTxt().getText() + ";"; } if (propPanel.getTypeCombo().getSelectedIndex() == 3) { modifiedRes.setMimeType("jrxml/subreport"); } else if (propPanel.getTypeCombo().getSelectedIndex() == 1) { modifiedRes.setMimeType("jrxml/label"); } else { modifiedRes.setMimeType("jrxml/report"); } if (StringUtils.isNotEmpty(modifiedRes.getMetaData())) { /* Assuming ReportResources only get edited by this class... metaDataStr = metaDataStr + ";" + modifiedRes.getMetaData();*/ log.info("overwriting existing AppResource metadata (" + modifiedRes.getMetaData() + ") with (" + metaDataStr + ")"); } modifiedRes.setMetaData(metaDataStr); AppResAndProps result = new AppResAndProps(modifiedRes, propPanel.getRepeats()); return result; } return null; }
From source file:junk.gui.HazardSpectrumApplication.java
void imgLabel_mouseClicked(MouseEvent e) { try {//from w w w . jav a2s . c o m this.getAppletContext().showDocument(new URL(OPENSHA_WEBSITE), "new_peer_win"); } catch (java.net.MalformedURLException ee) { JOptionPane.showMessageDialog(this, new String("No Internet Connection Available"), "Error Connecting to Internet", JOptionPane.OK_OPTION); } }