List of usage examples for javax.swing JOptionPane showConfirmDialog
public static int showConfirmDialog(Component parentComponent, Object message, String title, int optionType) throws HeadlessException
optionType
parameter. From source file:cz.moz.ctmanager.main.DetailsFrame.java
private void removeEmailButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_removeEmailButtonActionPerformed int selectedRow = emailTable.getSelectedRow(); if (selectedRow == -1) { JOptionPane.showMessageDialog(this, "Nothing Selected", "Error Message", JOptionPane.ERROR_MESSAGE); } else {/*from w w w . j a v a 2 s.co m*/ Object[] options = { "Are you Sure?" }; int choice = JOptionPane.showConfirmDialog(this, options, "Are you Sure", 2); if (choice == 0) { DefaultTableModel newTableModel = (DefaultTableModel) emailTable.getModel(); int selectedEmailID = (int) emailTable.getValueAt(emailTable.getSelectedRow(), 0); newTableModel.removeRow(selectedRow); emailsDao.removeEmail(selectedEmailID); } } }
From source file:wsattacker.plugin.intelligentdos.ui.dialog.Result_NB.java
private void saveBtnActionPerformed(java.awt.event.ActionEvent evt) {// GEN-FIRST:event_saveBtnActionPerformed try {/*w w w .j a v a2s . c o m*/ JFileChooser fileChooser = new JFileChooser(); int checker = fileChooser.showOpenDialog(null); if (checker == JFileChooser.APPROVE_OPTION) { File selectedFile = fileChooser.getSelectedFile(); String message = "The selected file already exists.\nOverwrite?"; if (!selectedFile.exists() || JOptionPane.showConfirmDialog(this, message, "Save result", JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) { if (!FilenameUtils.getExtension(selectedFile.getName()).equalsIgnoreCase(FILE_EXT_ZIP)) { selectedFile = new File(selectedFile.getAbsoluteFile() + "." + FILE_EXT_ZIP); } btnController.save(selectedFile); // default title and icon JOptionPane.showMessageDialog(this, "Result has been saved to filesystem."); } } } catch (IOException e) { JOptionPane.showMessageDialog(this, e.getMessage(), "Fehler beim Schreiben", JOptionPane.ERROR_MESSAGE); logger.warn(e, e); } catch (Exception e) { e.printStackTrace(); } }
From source file:com.holycityaudio.SpinCAD.SpinCADFile.java
public void fileSavePatchAs(SpinCADPatch p) { // Create a file chooser String savedPath = prefs.get("MRUPatchFolder", ""); final JFileChooser fc = new JFileChooser(savedPath); FileNameExtensionFilter filter = new FileNameExtensionFilter("SpinCAD Files", "spcd"); fc.setFileFilter(filter);//from w w w .j av a 2s. co m fc.setSelectedFile(new File(p.patchFileName)); int returnVal = fc.showSaveDialog(new JFrame()); // need to process user canceling box right here if (returnVal == JFileChooser.APPROVE_OPTION) { // In response to a button click: File fileToBeSaved = fc.getSelectedFile(); if (!fileToBeSaved.getAbsolutePath().endsWith(".spcd")) { fileToBeSaved = new File(fc.getSelectedFile() + ".spcd"); } int n = JOptionPane.YES_OPTION; if (fileToBeSaved.exists()) { JFrame frame = new JFrame(); n = JOptionPane.showConfirmDialog(frame, "Would you like to overwrite it?", "File already exists!", JOptionPane.YES_NO_OPTION); } if (n == JOptionPane.YES_OPTION) { try { String filePath = fileToBeSaved.getPath(); String fileName = fileToBeSaved.getName(); p.patchFileName = fileName; fileSavePatch(p); recentPatchFileList.add(fileToBeSaved); saveMRUPatchFolder(filePath); } catch (Exception e) { // thrown over in SpinCADFile.java e.printStackTrace(); SpinCADDialogs.MessageBox("File save failed!", "look at stack trace for info"); } finally { p.setChanged(false); } } } }
From source file:com.biosis.biosislite.vistas.inventario.MantenimientoTipo.java
private void btneliminarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btneliminarActionPerformed // TODO add your handling code here: accion = AbstractControlador.ELIMINAR; if (tbltipo.getSelectedRow() != -1) { Integer codigo = tbltipo.getSelectedRow(); Tipo tipo = tipoControlador.buscarPorId(lista.get(codigo).getId()); if (tipo != null) { if (JOptionPane.showConfirmDialog(null, "Desea Eliminar el Tipo?", "Mensaje del Sistema", JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) { int[] filas = tbltipo.getSelectedRows(); for (int i = 0; i < filas.length; i++) { Tipo empleado2 = lista.get(filas[0]); lista.remove(empleado2); tipoControlador.setSeleccionado(empleado2); tipoControlador.accion(accion); }// ww w.j ava 2 s . c om if (tipoControlador.accion(accion) == 3) { JOptionPane.showMessageDialog(null, "Tipo eliminado correctamente", "Mensaje del Sistema", JOptionPane.INFORMATION_MESSAGE); } else { JOptionPane.showMessageDialog(null, "Tipo no eliminada", "Mensaje del Sistema", JOptionPane.ERROR_MESSAGE); } } else { JOptionPane.showMessageDialog(null, "Tipo no eliminada", "Mensaje del Sistema", JOptionPane.ERROR_MESSAGE); } } } else { JOptionPane.showMessageDialog(null, "Debe seleccionar un Tipo", "Mensaje del Sistema", JOptionPane.ERROR_MESSAGE); } }
From source file:net.sf.jabref.gui.journals.ManageJournalsPanel.java
private boolean readyToClose() { Path filePath;//from ww w . jav a2 s. com if (newFile.isSelected()) { if (newNameTf.getText().isEmpty()) { if (tableModel.getRowCount() > 0) { JOptionPane.showMessageDialog(this, Localization.lang("You must choose a filename to store journal abbreviations"), Localization.lang("Store journal abbreviations"), JOptionPane.ERROR_MESSAGE); return false; } else { return true; } } else { filePath = Paths.get(newNameTf.getText()); return !Files.exists(filePath) || (JOptionPane.showConfirmDialog(this, Localization.lang("'%0' exists. Overwrite file?", filePath.getFileName().toString()), Localization.lang("Store journal abbreviations"), JOptionPane.OK_CANCEL_OPTION) == JOptionPane.OK_OPTION); } } return true; }
From source file:com.tiempometa.muestradatos.JMuestraDatos.java
private void verifyDataButtonActionPerformed(ActionEvent e) { if (ReaderContext.isFoxberryConnected() || (ReaderContext.isUsbConnected())) { if (userDataFrame.isVisible()) { userDataFrame.setVisible(false); ReaderContext.removeReadingListener(userDataFrame); ReaderContext.stopReading(); } else {// w w w . j a v a 2 s . c om try { ReaderContext.startReading(); ReaderContext.addReadingListener(userDataFrame); userDataFrame.setVisible(true); } catch (ReaderException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } } } else { JOptionPane.showConfirmDialog(this, "Se debe conectar a un lector primero", "Sin conexin a lectores", JOptionPane.WARNING_MESSAGE); } }
From source file:com.xmage.launcher.XMageLauncher.java
private void handleUpdate() { disableButtons();/*w w w.j ava 2s . com*/ if (!newJava && !newXMage) { int response = JOptionPane.showConfirmDialog(frame, messages.getString("force.update.message"), messages.getString("force.update.title"), JOptionPane.YES_NO_OPTION); if (response == JOptionPane.YES_OPTION) { UpdateTask update = new UpdateTask(progressBar, true); update.execute(); } else { enableButtons(); } } else { UpdateTask update = new UpdateTask(progressBar, false); update.execute(); } }
From source file:com.orthancserver.SelectImageDialog.java
public SelectImageDialog() { tree_ = new JTree(); tree_.addTreeWillExpandListener(new TreeWillExpandListener() { @Override/*from w ww. j a v a 2 s . c o m*/ public void treeWillExpand(TreeExpansionEvent event) throws ExpandVetoException { TreePath path = event.getPath(); if (path.getLastPathComponent() instanceof MyTreeNode) { MyTreeNode node = (MyTreeNode) path.getLastPathComponent(); node.LoadChildren((DefaultTreeModel) tree_.getModel()); } } @Override public void treeWillCollapse(TreeExpansionEvent event) throws ExpandVetoException { } }); tree_.addTreeSelectionListener(new TreeSelectionListener() { @Override public void valueChanged(TreeSelectionEvent e) { TreePath path = e.getNewLeadSelectionPath(); if (path != null) { MyTreeNode node = (MyTreeNode) path.getLastPathComponent(); if (node.UpdatePreview(preview_)) { selectedType_ = node.GetResourceType(); selectedUuid_ = node.GetUuid(); selectedConnection_ = node.GetConnection(); okButton_.setEnabled(true); } removeServer_.setEnabled(node.GetResourceType() == ResourceType.SERVER); } } }); tree_.addMouseListener(new MouseAdapter() { public void mousePressed(MouseEvent e) { TreePath path = tree_.getPathForLocation(e.getX(), e.getY()); if (path != null) { MyTreeNode node = (MyTreeNode) path.getLastPathComponent(); if (e.getClickCount() == 2 && node.GetResourceType() == ResourceType.INSTANCE) { // Double click on an instance, close the dialog isSuccess_ = true; setVisible(false); } } } }); final JPanel contentPanel = new JPanel(); getContentPane().setLayout(new BorderLayout()); contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5)); getContentPane().add(contentPanel, BorderLayout.CENTER); contentPanel.setLayout(new BorderLayout(0, 0)); { JSplitPane splitPane = new JSplitPane(); splitPane.setResizeWeight(0.6); contentPanel.add(splitPane); splitPane.setLeftComponent(new JScrollPane(tree_)); splitPane.setRightComponent(preview_); } { JPanel buttonPane = new JPanel(); buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT)); getContentPane().add(buttonPane, BorderLayout.SOUTH); { JButton btnAddServer = new JButton("Add server"); btnAddServer.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg) { OrthancConfigurationDialog dd = new OrthancConfigurationDialog(); dd.setLocationRelativeTo(null); // Center dialog on screen OrthancConnection orthanc = dd.ShowModal(); if (orthanc != null) { AddOrthancServer(orthanc); ((DefaultTreeModel) tree_.getModel()).reload(); } } }); buttonPane.add(btnAddServer); } { buttonPane.add(removeServer_); removeServer_.setEnabled(false); removeServer_.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg) { MyTreeNode selected = (MyTreeNode) tree_.getLastSelectedPathComponent(); if (selected.GetResourceType() == ResourceType.SERVER && JOptionPane.showConfirmDialog(null, "Remove server \"" + selected.getUserObject() + "\"?", "WARNING", JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) { ((DefaultTreeModel) tree_.getModel()).removeNodeFromParent(selected); } } }); } { okButton_.setEnabled(false); okButton_.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg) { isSuccess_ = true; setVisible(false); } }); buttonPane.add(okButton_); getRootPane().setDefaultButton(okButton_); } { JButton cancelButton = new JButton("Cancel"); cancelButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg) { setVisible(false); } }); buttonPane.add(cancelButton); } } setUndecorated(false); setSize(500, 500); setTitle("Select some series or some instance in Orthanc"); setModal(true); }
From source file:cz.moz.ctmanager.main.DetailsFrame.java
private void removePhoneButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_removePhoneButtonActionPerformed int selectedRow = phoneTable.getSelectedRow(); if (selectedRow == -1) { JOptionPane.showMessageDialog(this, "Nothing Selected", "Error Message", JOptionPane.ERROR_MESSAGE); } else {//from w ww . ja v a 2s .c om Object[] options = { "Are you Sure?" }; int choice = JOptionPane.showConfirmDialog(this, options, "Are you Sure", 2); if (choice == 0) { DefaultTableModel newTableModel = (DefaultTableModel) phoneTable.getModel(); int selectedPhoneID = (int) phoneTable.getValueAt(phoneTable.getSelectedRow(), 0); newTableModel.removeRow(selectedRow); phonesDao.removePhoneNumber(selectedPhoneID); } } }
From source file:com.tiempometa.muestradatos.JMuestraDatos.java
private void readTagButtonActionPerformed(ActionEvent e) { if (ReaderContext.isFoxberryConnected() || (ReaderContext.isUsbConnected())) { JReadTags readTag = new JReadTags(this, true); readTag.setVisible(true);// w w w . ja v a2 s . co m } else { JOptionPane.showConfirmDialog(this, "Se debe conectar a un lector primero", "Sin conexin a lectores", JOptionPane.WARNING_MESSAGE); } }