List of usage examples for javax.swing JOptionPane CLOSED_OPTION
int CLOSED_OPTION
To view the source code for javax.swing JOptionPane CLOSED_OPTION.
Click Source Link
CANCEL_OPTION
or NO_OPTION
. From source file:com.frostwire.gui.library.LibraryFilesTableMediator.java
/** * Override the default removal so we can actually stop sharing * and delete the file.// w w w .j ava 2 s . c o m * Deletes the selected rows in the table. * CAUTION: THIS WILL DELETE THE FILE FROM THE DISK. */ public void removeSelection() { int[] rows = TABLE.getSelectedRows(); if (rows.length == 0) return; if (TABLE.isEditing()) { TableCellEditor editor = TABLE.getCellEditor(); editor.cancelCellEditing(); } List<File> files = new ArrayList<File>(rows.length); // sort row indices and go backwards so list indices don't change when // removing the files from the model list Arrays.sort(rows); for (int i = rows.length - 1; i >= 0; i--) { File file = DATA_MODEL.getFile(rows[i]); files.add(file); } CheckBoxListPanel<File> listPanel = new CheckBoxListPanel<File>(files, new FileTextProvider(), true); listPanel.getList().setVisibleRowCount(4); // display list of files that should be deleted Object[] message = new Object[] { new MultiLineLabel(I18n.tr( "Are you sure you want to delete the selected file(s), thus removing it from your computer?"), 400), Box.createVerticalStrut(ButtonRow.BUTTON_SEP), listPanel, Box.createVerticalStrut(ButtonRow.BUTTON_SEP) }; // get platform dependent options which are displayed as buttons in the dialog Object[] removeOptions = createRemoveOptions(); int option = JOptionPane.showOptionDialog(MessageService.getParentComponent(), message, I18n.tr("Message"), JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, removeOptions, removeOptions[0] /* default option */); if (option == removeOptions.length - 1 /* "cancel" option index */ || option == JOptionPane.CLOSED_OPTION) { return; } // remove still selected files List<File> selected = listPanel.getSelectedElements(); List<String> undeletedFileNames = new ArrayList<String>(); for (File file : selected) { // stop seeding if seeding BittorrentDownload dm = null; if ((dm = TorrentUtil.getDownloadManager(file)) != null) { dm.setDeleteDataWhenRemove(false); dm.setDeleteTorrentWhenRemove(false); BTDownloadMediator.instance().remove(dm); } // close media player if still playing if (MediaPlayer.instance().isThisBeingPlayed(file)) { MediaPlayer.instance().stop(); MPlayerMediator.instance().showPlayerWindow(false); } // removeOptions > 2 => OS offers trash options boolean removed = FileUtils.delete(file, removeOptions.length > 2 && option == 0 /* "move to trash" option index */); if (removed) { DATA_MODEL.remove(DATA_MODEL.getRow(file)); } else { undeletedFileNames.add(getCompleteFileName(file)); } } clearSelection(); if (undeletedFileNames.isEmpty()) { return; } // display list of files that could not be deleted message = new Object[] { new MultiLineLabel(I18n.tr( "The following files could not be deleted. They may be in use by another application or are currently being downloaded to."), 400), Box.createVerticalStrut(ButtonRow.BUTTON_SEP), new JScrollPane(createFileList(undeletedFileNames)) }; JOptionPane.showMessageDialog(MessageService.getParentComponent(), message, I18n.tr("Error"), JOptionPane.ERROR_MESSAGE); super.removeSelection(); }
From source file:com.mirth.connect.client.ui.ChannelPanel.java
private boolean promptSave(boolean force) { int option;// w w w . j a v a 2 s . c o m if (force) { option = JOptionPane.showConfirmDialog(parent, "You must save the channel group changes before continuing. Would you like to save now?"); } else { option = JOptionPane.showConfirmDialog(parent, "Would you like to save the channel groups?"); } if (option == JOptionPane.YES_OPTION) { return doSaveGroups(false); } else if (option == JOptionPane.CANCEL_OPTION || option == JOptionPane.CLOSED_OPTION || (option == JOptionPane.NO_OPTION && force)) { return false; } return true; }
From source file:edu.ku.brc.af.ui.db.DatabaseLoginPanel.java
/** * Creates the UI for the login and hooks up any listeners. * @param isDlg whether the parent is a dialog (false mean JFrame) * @param iconName the icon that will be shown in the panel * @param engageUPPrefs whether it should load and save the username password into the prefs * @param helpContext the help context to use. */// w w w. j a v a2 s . c o m protected void createUI(final boolean isDlg, final String iconName, final String helpContext) { final boolean isNotEmbedded = !DBConnection.getInstance().isEmbedded() && !UIRegistry.isMobile(); final AppPreferences localPrefs = AppPreferences.getLocalPrefs(); //Font cachedFont = UIManager.getFont("JLabel.font"); SkinItem skinItem = SkinsMgr.getSkinItem("LoginPanel"); if (skinItem != null) { skinItem.pushFG("Label.foreground"); } if (isNotEmbedded) { SpinnerModel portModel = new SpinnerNumberModel(3306, //initial value 0, //min Integer.MAX_VALUE, //max 1); //step portSpinner = new JSpinner(portModel); JSpinner.NumberEditor editor = new JSpinner.NumberEditor(portSpinner, "#"); portSpinner.setEditor(editor); portSpinner.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { DatabaseDriverInfo drvInfo = dbDrivers.get(dbDriverCBX.getSelectedIndex()); if (drvInfo != null && isNotEmbedded && portSpinner != null) { drvInfo.setPort((Integer) portSpinner.getValue()); } } }); setControlSize(portSpinner); } // First create the controls and hook up listeners dbPickList = new PropertiesPickListAdapter("login.databases"); //$NON-NLS-1$ svPickList = new PropertiesPickListAdapter("login.servers"); //$NON-NLS-1$ username = createTextField(15); password = createPasswordField(15); FocusAdapter focusAdp = new FocusAdapter() { @Override public void focusGained(FocusEvent e) { super.focusGained(e); JTextField tf = (JTextField) e.getSource(); tf.selectAll(); } }; username.addFocusListener(focusAdp); password.addFocusListener(focusAdp); databases = new ValComboBox(dbPickList); if (databases.getComboBox() instanceof Java2sAutoComboBox) { ((Java2sAutoComboBox) databases.getComboBox()).setCaseSensitive(true); } servers = new ValComboBox(svPickList); dbPickList.setComboBox(databases); svPickList.setComboBox(servers); setControlSize(password); setControlSize(databases); setControlSize(servers); if (masterUsrPwdProvider != null) { editKeyInfoBtn = UIHelper.createI18NButton("CONFIG_MSTR_KEY"); editKeyInfoBtn.setIcon(IconManager.getIcon("Key", IconManager.IconSize.Std20)); editKeyInfoBtn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (masterUsrPwdProvider != null && databases != null) { String itemName = null; if (databases.getComboBox().getSelectedItem() instanceof String) { itemName = (String) databases.getComboBox().getSelectedItem(); } else { PickListItemIFace pli = (PickListItemIFace) databases.getComboBox().getSelectedItem(); if (pli != null && pli.getValue() != null) { itemName = pli.getValue(); } } if (itemName != null) { masterUsrPwdProvider.editMasterInfo(username.getText(), itemName, false); } } } }); } rememberUsernameCBX = createCheckBox(getResourceString("rememberuser")); //$NON-NLS-1$ rememberUsernameCBX.setEnabled(engageUPPrefs); statusBar = new JStatusBar(); statusBar.setErrorIcon(IconManager.getIcon("Error", IconManager.IconSize.Std16)); //$NON-NLS-1$ cancelBtn = createButton(getResourceString("CANCEL")); //$NON-NLS-1$ loginBtn = createButton(getResourceString("Login")); //$NON-NLS-1$ helpBtn = createButton(getResourceString("HELP")); //$NON-NLS-1$ forwardImgIcon = IconManager.getIcon("Forward"); //$NON-NLS-1$ downImgIcon = IconManager.getIcon("Down"); //$NON-NLS-1$ moreBtn = new JCheckBox(getResourceString("LOGIN_DLG_MORE"), forwardImgIcon); // XXX I18N //$NON-NLS-1$ setControlSize(moreBtn); // Extra dbDrivers = DatabaseDriverInfo.getDriversList(); dbDriverCBX = createComboBox(dbDrivers); dbDriverCBX.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { updateUIControls(); DatabaseDriverInfo drvInfo = dbDrivers.get(dbDriverCBX.getSelectedIndex()); if (drvInfo != null && isNotEmbedded && portSpinner != null) { Integer defPort = drvInfo.getPortAsInt(); int portFromPref = localPrefs.getInt(LOGIN_PORT, defPort); portSpinner.setValue(portFromPref); drvInfo.setPort(portFromPref); } } }); if (dbDrivers.size() > 0) { if (dbDrivers.size() == 1) { dbDriverCBX.setSelectedIndex(0); dbDriverCBX.setEnabled(false); } else { String selectedStr = localPrefs.get("login.dbdriver_selected", "MySQL"); //$NON-NLS-1$ //$NON-NLS-2$ int inx = Collections.binarySearch(dbDrivers, new DatabaseDriverInfo(selectedStr, null, null, false, null)); dbDriverCBX.setSelectedIndex(inx > -1 ? inx : -1); } } else { JOptionPane.showConfirmDialog(null, getResourceString("NO_DBDRIVERS"), //$NON-NLS-1$ getResourceString("NO_DBDRIVERS_TITLE"), JOptionPane.CLOSED_OPTION); //$NON-NLS-1$ System.exit(1); } addFocusListenerForTextComp(username); addFocusListenerForTextComp(password); addKeyListenerFor(username, !isDlg); addKeyListenerFor(password, !isDlg); addKeyListenerFor(databases.getTextField(), !isDlg); addKeyListenerFor(servers.getTextField(), !isDlg); if (!isDlg) { addKeyListenerFor(loginBtn, true); } rememberUsernameCBX.setSelected(engageUPPrefs ? localPrefs.getBoolean("login.rememberuser", false) : false); //$NON-NLS-1$ cancelBtn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (dbListener != null) { dbListener.cancelled(); } } }); loginBtn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { doLogin(); } }); HelpMgr.registerComponent(helpBtn, helpContext); //$NON-NLS-1$ moreBtn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (extraPanel.isVisible()) { if (dbDriverCBX.getSelectedIndex() != -1) { extraPanel.setVisible(false); moreBtn.setIcon(forwardImgIcon); } } else { extraPanel.setVisible(true); moreBtn.setIcon(downImgIcon); } if (window != null) { window.pack(); } } }); // Ask the PropertiesPickListAdapter to set the index from the prefs dbPickList.setSelectedIndex(); svPickList.setSelectedIndex(); servers.getTextField().addKeyListener(new KeyAdapter() { @Override public void keyReleased(KeyEvent e) { updateUIControls(); } }); databases.getTextField().addKeyListener(new KeyAdapter() { @Override public void keyReleased(KeyEvent e) { updateUIControls(); } }); databases.getTextField().addFocusListener(new FocusAdapter() { String server = null; private String getServerStr() { String serverStr = null; Object serverObj = servers.getValue(); if (serverObj != null) { serverStr = serverObj.toString(); } return serverStr; } @Override public void focusGained(FocusEvent e) { server = getServerStr(); } @Override public void focusLost(FocusEvent e) { if (server != null) { String newVal = getServerStr(); if (newVal != null && !newVal.equals(server)) { setUsrPwdControlsFromPrefs(); } } } }); setUsrPwdControlsFromPrefs(); // Layout the form PanelBuilder formBuilder = new PanelBuilder(new FormLayout("p,3dlu,p:g", "p,2dlu,p,2dlu,p,2dlu,p,2dlu,p")); //$NON-NLS-1$ //$NON-NLS-2$ CellConstraints cc = new CellConstraints(); formBuilder.addSeparator(getResourceString("LOGINLABEL"), cc.xywh(1, 1, 3, 1)); //$NON-NLS-1$ addLine("username", username, formBuilder, cc, 3); //$NON-NLS-1$ addLine("password", password, formBuilder, cc, 5); //$NON-NLS-1$ formBuilder.add(moreBtn, cc.xy(3, 7)); PanelBuilder extraPanelBlder = new PanelBuilder(new FormLayout("p,3dlu,p:g", //$NON-NLS-1$ UIHelper.createDuplicateJGoodiesDef("p", "2dlu", isNotEmbedded ? 9 : 11))); //$NON-NLS-1$ //$NON-NLS-2$ extraPanel = extraPanelBlder.getPanel(); extraPanel.setBorder(BorderFactory.createEmptyBorder(2, 2, 4, 2)); //extraPanelBlder.addSeparator("", cc.xywh(1, 1, 3, 1)); //$NON-NLS-1$ int y = 1; y = addLine(null, rememberUsernameCBX, extraPanelBlder, cc, y); y = addLine("databases", databases, extraPanelBlder, cc, y); //$NON-NLS-1$ y = addLine("servers", servers, extraPanelBlder, cc, y); //$NON-NLS-1$ y = addLine("driver", dbDriverCBX, extraPanelBlder, cc, y); //$NON-NLS-1$ if (isNotEmbedded) { y = addLine("port", portSpinner, extraPanelBlder, cc, y); //$NON-NLS-1$ } if (editKeyInfoBtn != null) { PanelBuilder pb = new PanelBuilder(new FormLayout("p,f:p:g", "p")); pb.add(editKeyInfoBtn, cc.xy(1, 1)); y = addLine(null, pb.getPanel(), extraPanelBlder, cc, y); pb.getPanel().setOpaque(false); } extraPanel.setVisible(false); formBuilder.add(extraPanelBlder.getPanel(), cc.xywh(3, 9, 1, 1)); PanelBuilder outerPanel = new PanelBuilder(new FormLayout("p,3dlu,p:g", "t:p,2dlu,p,2dlu,p"), this); //$NON-NLS-1$ //$NON-NLS-2$ JLabel icon = StringUtils.isNotEmpty(iconName) ? new JLabel(IconManager.getIcon(iconName)) : null; if (icon != null) { icon.setBorder(BorderFactory.createEmptyBorder(10, 10, 2, 2)); } formBuilder.getPanel().setBorder(BorderFactory.createEmptyBorder(10, 5, 0, 5)); if (icon != null) { outerPanel.add(icon, cc.xy(1, 1)); } JPanel btnPanel = ButtonBarFactory.buildOKCancelHelpBar(loginBtn, cancelBtn, helpBtn); outerPanel.add(formBuilder.getPanel(), cc.xy(3, 1)); outerPanel.add(btnPanel, cc.xywh(1, 3, 3, 1)); outerPanel.add(statusBar, cc.xywh(1, 5, 3, 1)); formBuilder.getPanel().setOpaque(false); outerPanel.getPanel().setOpaque(false); btnPanel.setOpaque(false); updateUIControls(); if (skinItem != null) { skinItem.popFG("Label.foreground"); } if (AppPreferences.getLocalPrefs().getBoolean(expandExtraPanelName, false)) { extraPanel.setVisible(true); moreBtn.setIcon(downImgIcon); } }
From source file:DialogDemo.java
/** Creates the reusable dialog. */ public CustomDialog(Frame aFrame, String aWord, DialogDemo parent) { super(aFrame, true); dd = parent;/*from www . j a v a 2 s . c o m*/ magicWord = aWord.toUpperCase(); setTitle("Quiz"); textField = new JTextField(10); // Create an array of the text and components to be displayed. String msgString1 = "What was Dr. SEUSS's real last name?"; String msgString2 = "(The answer is \"" + magicWord + "\".)"; Object[] array = { msgString1, msgString2, textField }; // Create an array specifying the number of dialog buttons // and their text. Object[] options = { btnString1, btnString2 }; // Create the JOptionPane. optionPane = new JOptionPane(array, JOptionPane.QUESTION_MESSAGE, JOptionPane.YES_NO_OPTION, null, options, options[0]); // Make this dialog display it. setContentPane(optionPane); // Handle window closing correctly. setDefaultCloseOperation(DO_NOTHING_ON_CLOSE); addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent we) { /* * Instead of directly closing the window, we're going to change the * JOptionPane's value property. */ optionPane.setValue(new Integer(JOptionPane.CLOSED_OPTION)); } }); // Ensure the text field always gets the first focus. addComponentListener(new ComponentAdapter() { public void componentShown(ComponentEvent ce) { textField.requestFocusInWindow(); } }); // Register an event handler that puts the text into the option pane. textField.addActionListener(this); // Register an event handler that reacts to option pane state changes. optionPane.addPropertyChangeListener(this); }
From source file:edu.ku.brc.specify.utilapps.sp5utils.Sp5Forms.java
/** * //www . ja va2 s.c o m */ protected void startup() { try { final SpecifyDBConverter converter = new SpecifyDBConverter(); if (converter.selectedDBsToConvert(true)) { namePair = converter.chooseTable("Select a DB for Forms", "Select a Form", true); hostName = converter.getHostName(); itUsrPwd = converter.getItUsrPwd(); } } catch (SQLException ex) { ex.printStackTrace(); JOptionPane.showConfirmDialog(null, "The Converter was unable to login.", "Error", JOptionPane.CLOSED_OPTION); } if (namePair != null) { DatabaseDriverInfo driverInfo = DatabaseDriverInfo.getDriver("MySQL"); String oldConnStr = driverInfo.getConnectionStr(DatabaseDriverInfo.ConnectionType.Open, hostName, namePair.second, itUsrPwd.first, itUsrPwd.second, driverInfo.getName()); // This will log us in and return true/false // This will connect without specifying a DB, which allows us to create the DB if (!tryLogin(driverInfo.getDriverClassName(), driverInfo.getDialectClassName(), namePair.second, oldConnStr, itUsrPwd.first, itUsrPwd.second)) { log.error("Failed connection string: " + driverInfo.getConnectionStr(DatabaseDriverInfo.ConnectionType.Open, hostName, namePair.second, itUsrPwd.first, itUsrPwd.second, driverInfo.getName())); throw new RuntimeException("Couldn't login into [" + namePair.second + "] " + DBConnection.getInstance().getErrorMsg()); } process(); } else { JOptionPane.showConfirmDialog(null, "The Converter was unable to login.", "Error", JOptionPane.CLOSED_OPTION); System.exit(0); } }
From source file:edu.ku.brc.specify.utilapps.sp5utils.Sp5Forms.java
protected static DBConnection getNewDBConnection() { Pair<String, String> namePair = null; Pair<String, String> usrNmPwd = null; final SpecifyDBConverter converter = new SpecifyDBConverter(); try {//w w w . ja v a 2s. c o m if (converter.selectedDBsToConvert(true)) { namePair = converter.chooseTable("Choose", "Select a Specify 6 Database", false); usrNmPwd = converter.getItUsrPwd(); } } catch (SQLException ex) { ex.printStackTrace(); JOptionPane.showConfirmDialog(null, "The Sp5Forms was unable to login.", "Error", JOptionPane.CLOSED_OPTION); } if (namePair != null) { DatabaseDriverInfo driverInfo = DatabaseDriverInfo.getDriver("MySQL"); String oldConnStr = driverInfo.getConnectionStr(DatabaseDriverInfo.ConnectionType.Open, converter.getHostName(), namePair.second, usrNmPwd.first, usrNmPwd.second, driverInfo.getName()); DBConnection dbConn = DBConnection.createInstance(driverInfo.getDriverClassName(), driverInfo.getDialectClassName(), namePair.second, oldConnStr, usrNmPwd.first, usrNmPwd.second); Connection connection = dbConn.createConnection(); if (connection != null) { try { connection.close(); return dbConn; } catch (SQLException ex) { // do nothing } } } return null; }
From source file:com.iucosoft.eavertizare.gui.MainJFrame.java
private void jButtonDeleteFirmaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonDeleteFirmaActionPerformed int index = jListFirma.getSelectedIndex(); if (index != -1) { Object numeFirma = jListFirma.getModel().getElementAt(index); firma = firmaDao.findByName((String) numeFirma); int rez = JOptionPane.showConfirmDialog(this, "Esti sigur vrei sa sterg firma ?", "Question", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE); switch (rez) { case JOptionPane.YES_OPTION: int idConfiguratie = firma.getConfiguratii().getId(); firmaDao.dropTableClients(firma.getTabelaClientiLocal()); System.out.println("conf id = " + idConfiguratie); firmaDao.delete(firma.getId()); configuratiiDao.delete(idConfiguratie); JOptionPane.showMessageDialog(this, "Firma stersa cu success", "Succes", JOptionPane.INFORMATION_MESSAGE); break; case JOptionPane.NO_OPTION: case JOptionPane.CLOSED_OPTION: break; }/*from w w w . j av a 2s .c om*/ refreshFrame(); } else { JOptionPane.showMessageDialog(this, "Selectati firma!", "Info", JOptionPane.INFORMATION_MESSAGE); } }
From source file:at.becast.youploader.gui.FrmMain.java
protected void startUploads() { UploadMgr.setSpeed_limit(speed);//from w ww .jav a2 s . co m if ("0".equals(Main.s.setting.get("tos_agreed")) && !this.tos) { if (Main.debug) LOG.debug("Asking about ToS Agreement"); //Dummy JFrame to keep Dialog on top JFrame frmOpt = new JFrame(); frmOpt.setAlwaysOnTop(true); JCheckBox checkbox = new JCheckBox(LANG.getString("frmMain.tos.Remember")); String message = LANG.getString("frmMain.tos.Message"); Object[] params = { message, checkbox }; int n; do { n = JOptionPane.showConfirmDialog(frmOpt, params, LANG.getString("frmMain.tos.Title"), JOptionPane.YES_NO_OPTION, JOptionPane.PLAIN_MESSAGE); } while (n == JOptionPane.CLOSED_OPTION); if (n == JOptionPane.OK_OPTION) { if (Main.debug) LOG.debug("Agreed to ToS"); if (checkbox.isSelected()) { Main.s.setting.put("tos_agreed", "1"); Main.s.save("tos_agreed"); } this.tos = true; UploadMgr.start(); } frmOpt.dispose(); } else { if (Main.debug) LOG.debug("Previously agreed to ToS"); UploadMgr.start(); } }
From source file:org.forester.archaeopteryx.TreePanel.java
final private void deleteNodeOrSubtree(final PhylogenyNode node) { if (getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.UNROOTED) { errorMessageNoCutCopyPasteInUnrootedDisplay(); return;//from ww w .j a v a 2 s . c om } if (node.isRoot()) { JOptionPane.showMessageDialog(this, "Cannot delete entire tree", "Attempt to delete entire tree", JOptionPane.ERROR_MESSAGE); return; } final String label = getASimpleTextRepresentationOfANode(node); final Object[] options = { "Node only", "Entire subtree", "Cancel" }; final int r = JOptionPane.showOptionDialog(this, "Delete" + label + "?", "Delete Node/Subtree", JOptionPane.CLOSED_OPTION, JOptionPane.QUESTION_MESSAGE, null, options, options[2]); boolean node_only = true; if (r == 1) { node_only = false; } else if (r != 0) { return; } if (node_only) { PhylogenyMethods.removeNode(node, _phylogeny); } else { _phylogeny.deleteSubtree(node, true); } _phylogeny.externalNodesHaveChanged(); _phylogeny.hashIDs(); _phylogeny.recalculateNumberOfExternalDescendants(true); resetNodeIdToDistToLeafMap(); setEdited(true); repaint(); }
From source file:com.iucosoft.eavertizare.gui.MainJFrame.java
private void sendAvertizare(String tipAvertizare) { int selectedRowIndex = jTableClients.getSelectedRow(); Client client = null;//from w w w . jav a 2 s. c o m int contor = 0; String mesaj = ""; Icon icon = new ImageIcon(getClass().getResource("/images/help_and_support.png")); if (selectedRowIndex != -1) { int rez = JOptionPane.showConfirmDialog(this, "Doriti sa modificati mesajul ?", "Question", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, icon); switch (rez) { case JOptionPane.YES_OPTION: client = cientForIndex(selectedRowIndex); sendAvertizareJFrame(client.getFirma(), client, tipAvertizare); break; case JOptionPane.NO_OPTION: client = cientForIndex(selectedRowIndex); SimpleDateFormat sdf = new SimpleDateFormat("dd/M/yyyy"); String mesajClient = client.getFirma().getMesajPentruClienti() .replaceFirst("nume", client.getNume()).replaceFirst("prenume", client.getPrenume()) .replaceFirst("data", sdf.format(client.getDateExpirare()).toString()) .replaceFirst("compania", client.getFirma().getNumeFirma()); switch (tipAvertizare) { case "SMS AND E-MAIL": mesaj = "Sms si e-mail"; { try { client.setTrimis(true); clientsDao.update(client.getFirma(), client); smsSender.sendSms(client.getNrTelefon(), mesajClient); mailSender.sendMail(client.getEmail(), "E-avetizare", mesajClient); } catch (Exception ex) { //Logger.getLogger(MainJFrame.class.getName()).log(Level.SEVERE, null, ex); JOptionPane.showMessageDialog(new JFrame(), "Verificai conexiunea la internet!\n" + ex, "Error", JOptionPane.ERROR_MESSAGE); contor = 1; } } clientiTableModel.refreshModel(); break; case "SMS": mesaj = "Sms"; try { smsSender.sendSms(client.getNrTelefon(), mesajClient); } catch (Exception ex) { //Logger.getLogger(MainJFrame.class.getName()).log(Level.SEVERE, null, ex); JOptionPane.showMessageDialog(new JFrame(), "Verificai conexiunea la internet!\n" + ex, "Error", JOptionPane.ERROR_MESSAGE); contor = 1; } break; case "E-MAIL": mesaj = "E-mail"; try { mailSender.sendMail(client.getEmail(), "E-avetizare", mesajClient); } catch (Exception ex) { //Logger.getLogger(MainJFrame.class.getName()).log(Level.SEVERE, null, ex); JOptionPane.showMessageDialog(new JFrame(), "Verificai conexiunea la internet!\n" + ex, "Error", JOptionPane.ERROR_MESSAGE); contor = 1; } break; } if (contor != 1) { JOptionPane.showMessageDialog(MainJFrame.this, mesaj + " transmis cu succes!", "Info", JOptionPane.INFORMATION_MESSAGE); } break; case JOptionPane.CLOSED_OPTION: break; } } else { JOptionPane.showMessageDialog(this, "Selectati clientul!", "Info", JOptionPane.INFORMATION_MESSAGE); } }