List of usage examples for javax.swing JOptionPane YES_OPTION
int YES_OPTION
To view the source code for javax.swing JOptionPane YES_OPTION.
Click Source Link
From source file:edu.ku.brc.specify.tools.schemalocale.SchemaLocalizerFrame.java
/** * /*from w ww . j a va 2s . c om*/ */ protected void shutdown() { if (schemaLocPanel.hasChanged()) { int rv = JOptionPane.showConfirmDialog(this, getResourceString("SchemaLocalizerFrame.SV_CHNGES"), //$NON-NLS-1$ getResourceString("SchemaLocalizerFrame.CHGS_SAVED"), JOptionPane.YES_NO_OPTION); // I18N //$NON-NLS-1$ if (rv == JOptionPane.YES_OPTION) { write(); } } //helper.dumpAsNew(panel.getTables()); setVisible(false); System.exit(0); }
From source file:com.clough.android.adbv.view.UpdateTableDialog.java
private void showTableChangeOptionMenu(int x, int y, final int rowIndex) { JPopupMenu tableChangeOptionPopupMenu = new JPopupMenu(); JMenuItem newRowMenuItem = new JMenuItem("Add row"); newRowMenuItem.addActionListener(new ActionListener() { @Override/*from w ww.j a v a 2 s. c om*/ public void actionPerformed(ActionEvent e) { new AddUpdateRowDialog(defaultTableModel, rowController, columnNames, null, -1).setVisible(true); } }); JMenuItem updateRowMenuItem = new JMenuItem("Update row"); updateRowMenuItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { Object[] row = new Object[columnNames.length]; for (int columnIndex = 0; columnIndex < row.length; columnIndex++) { row[columnIndex] = defaultTableModel.getValueAt(rowIndex, columnIndex); } new AddUpdateRowDialog(defaultTableModel, rowController, columnNames, row, rowIndex) .setVisible(true); tableColumnAdjuster.adjustColumns(); } }); JMenuItem removeRowMenuItem = new JMenuItem("Remove row"); removeRowMenuItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (JOptionPane.showConfirmDialog(null, "Are you sure you want to remove this row?", "Remove row", JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) { defaultTableModel.removeRow(rowIndex); rowController.removeRow(rowIndex); tableColumnAdjuster.adjustColumns(); } } }); tableChangeOptionPopupMenu.add(newRowMenuItem); tableChangeOptionPopupMenu.add(updateRowMenuItem); tableChangeOptionPopupMenu.add(removeRowMenuItem); tableChangeOptionPopupMenu.show(this, x, y); }
From source file:com.floreantpos.ui.views.order.OrderView.java
private void addActionButtonPanel() { ticketView.getTicketViewerTable().getSelectionModel().addListSelectionListener(new ListSelectionListener() { @Override/*from w w w . j av a 2 s. co m*/ public void valueChanged(ListSelectionEvent e) { if (!e.getValueIsAdjusting()) { handleTicketItemSelection(); } } }); btnDone.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { try { ticketView.doFinishOrder(); } catch (StaleObjectStateException x) { POSMessageDialog.showError(Application.getPosWindow(), Messages.getString("TicketView.22")); //$NON-NLS-1$ return; } catch (PosException x) { POSMessageDialog.showError(x.getMessage()); } catch (Exception x) { POSMessageDialog.showError(Application.getPosWindow(), POSConstants.ERROR_MESSAGE, x); } } }); btnCancel.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { if (ticketView.isCancelable()) { ticketView.doCancelOrder(); return; } int result = POSMessageDialog.showYesNoQuestionDialog(null, "Items have been sent to kitchen, are you sure to cancel this ticket?", "Confirm"); if (result != JOptionPane.YES_OPTION) { return; } ticketView.doCancelOrder(); ticketView.setAllowToLogOut(true); } }); btnSend.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { try { ticketView.sendTicketToKitchen(); ticketView.updateView(); POSMessageDialog.showMessage("Items sent to kitchen"); } catch (StaleObjectStateException x) { POSMessageDialog.showError(Application.getPosWindow(), Messages.getString("TicketView.22")); //$NON-NLS-1$ return; } catch (PosException x) { POSMessageDialog.showError(x.getMessage()); } catch (Exception x) { POSMessageDialog.showError(Application.getPosWindow(), POSConstants.ERROR_MESSAGE, x); } } }); btnOrderType.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { // doViewOrderInfo(); //doChangeOrderType(); fix } }); btnCustomer.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { doAddEditCustomer(); } }); btnMisc.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { doInsertMisc(evt); } }); btnGuestNo.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnCustomerNumberActionPerformed(); } }); btnSeatNo.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { doAddSeatNumber(); } }); btnTableNumber.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { updateTableNumber(); } }); btnCookingInstruction.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { doAddCookingInstruction(); } }); btnHold.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { OrderType orderType = currentTicket.getOrderType(); if (orderType.isShowTableSelection() && orderType.isRequiredCustomerData()//fix && !Application.getCurrentUser().hasPermission(UserPermission.HOLD_TICKET)) { // String password = PasswordEntryDialog.show(Application.getPosWindow(), "Please enter privileged password"); if (StringUtils.isEmpty(password)) { return; } User user2 = UserDAO.getInstance().findUserBySecretKey(password); if (user2 == null) { POSMessageDialog.showError(Application.getPosWindow(), "No user found with that secret key"); return; } else { if (!user2.hasPermission(UserPermission.HOLD_TICKET)) { POSMessageDialog.showError(Application.getPosWindow(), "No permission"); return; } } } if (!currentTicket.isBarTab() && (ticketView.getTicket().getTicketItems() == null || ticketView.getTicket().getTicketItems().size() == 0)) { POSMessageDialog.showError(com.floreantpos.POSConstants.TICKET_IS_EMPTY_); return; } ticketView.doHoldOrder(); ticketView.setAllowToLogOut(true); } }); // btnAddOn.addActionListener(new ActionListener() { // @Override // public void actionPerformed(ActionEvent e) { // doAddAddOn(); // } // }); btnDiscount.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { addDiscount(); } }); actionButtonPanel.add(btnOrderType); actionButtonPanel.add(btnCustomer); actionButtonPanel.add(btnTableNumber); actionButtonPanel.add(btnGuestNo); actionButtonPanel.add(btnSeatNo); actionButtonPanel.add(btnCookingInstruction); // actionButtonPanel.add(btnAddOn); actionButtonPanel.add(btnMisc); actionButtonPanel.add(btnHold); actionButtonPanel.add(btnSend); actionButtonPanel.add(btnCancel); actionButtonPanel.add(btnDone); btnCookingInstruction.setEnabled(false); // btnAddOn.setEnabled(false); }
From source file:dev.agustin.serializer.MainWindow.java
private void doExit() { if (hasChanged) { int state = JOptionPane.showConfirmDialog(this, "File has been changed. Save before exit?"); if (state == JOptionPane.YES_OPTION) { saveJpctFile();/*w ww . j a v a2s . c om*/ } else if (state == JOptionPane.CANCEL_OPTION) { return; } } System.exit(0); }
From source file:de.freese.base.swing.mac_os_x.MyApp.java
/** * General quit handler; fed to the OSXAdapter as the method to call when a * system quit event<br>/* w w w . ja v a 2s. c o m*/ * occurs. A quit event is triggered by Cmd-Q, selecting Quit from the * application or<br> * Dock menu, or logging out. * <p/> * @return boolean */ public boolean quit() { int option = JOptionPane.showConfirmDialog(this, "Are you sure you want to quit?", "Quit?", JOptionPane.YES_NO_OPTION); return (option == JOptionPane.YES_OPTION); }
From source file:fur.shadowdrake.minecraft.InstallPanel.java
@Deprecated private boolean registerRhaokarLightPack(File path) throws NetworkException { FileOutputStream fos;// w w w. j ava2 s . c o m try { fos = new FileOutputStream(new File(path, "modpack")); fos.write("rhaokar_light".getBytes()); fos.close(); } catch (FileNotFoundException ex) { return false; } catch (IOException ex) { return false; } if (new File(path, "resourcepacks/01.zip").isFile()) { downloadFile("manifest.json"); } else if (new File(path, "resourcepacks/Soatex_Custom.zip").isFile()) { try { EventQueue.invokeAndWait(() -> { result = JOptionPane.showConfirmDialog(InstallPanel.this, "An old version of the graphics pack was detected. Do you want to keep it?\nIf you choose no, your selection in addons will be downloaded.", "Addons", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE); }); } catch (InterruptedException | InvocationTargetException ex) { Logger.getLogger(InstallPanel.class.getName()).log(Level.SEVERE, null, ex); } switch (result) { case JOptionPane.YES_OPTION: downloadFile("manifest_old.json", "manifest.json"); break; default: new File(path, "mods/ShadersModCore-v2.3.31-mc1.7.10-f.jar").delete(); try { cleanDirectory(new File(path, "resourcepacks")); } catch (IOException ex) { } try { deleteDirectory(new File(path, "shaderpacks")); } catch (IOException ex) { } downloadAddons(); } } return true; }
From source file:marytts.tools.voiceimport.DatabaseImportMain.java
protected void askIfSave() throws IOException { if (bnl.hasChanged()) { int answer = JOptionPane.showOptionDialog(this, "Do you want to save the list of basenames?", "Save?", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, null, null); if (answer == JOptionPane.YES_OPTION) { JFileChooser fc = new JFileChooser(); fc.setSelectedFile(new File(db.getProp(db.BASENAMEFILE))); int returnVal = fc.showSaveDialog(this); if (returnVal == JFileChooser.APPROVE_OPTION) { bnl.write(fc.getSelectedFile()); }//from w w w .j a v a 2s .com } } else { System.exit(0); } }
From source file:edu.ku.brc.specify.tasks.CleanupToolsTask.java
/** * /*from w ww .j av a 2 s. c om*/ */ private void doAgentFuzzyMatches() { int rv = JOptionPane.YES_OPTION; int matchCnt = AgentCleanupProcessor.getExactMatchCount(); if (matchCnt > 0) { //String msg = UIRegistry.getLocalizedMessage("CLNUP_HAS_EXACT_AG_MATCHES", matchCnt); // I18N String msg = String.format( "There were %d exact matches.\nIt is recommended to resolve these first before merging using 'fuzzy matches'.\n\nDo you wish to continue with 'fuzzy matches' ?", matchCnt); rv = UIRegistry.askYesNoLocalized("Continue", "Close", msg, "CLNUP_HAS_EXACT_AG_MATCHES_TITLE"); } if (rv == JOptionPane.YES_OPTION) { AgentCleanupIndexer ac = new AgentCleanupIndexer(); //ac.testLastNames(); agentProcessor = new AgentCleanupProcessor(ac, false); agentProcessor.doBuildLuceneIndex(); } }
From source file:com.intuit.tank.proxy.ProxyApp.java
private JPanel getTransactionTable() { JPanel frame = new JPanel(new BorderLayout()); model = new TransactionTableModel(); final JTable table = new TransactionTable(model); final TableRowSorter<TableModel> sorter = new TableRowSorter<TableModel>(model); table.setRowSorter(sorter);//from w w w. j a va2 s .c o m final JPopupMenu pm = new JPopupMenu(); JMenuItem item = new JMenuItem("Delete Selected"); item.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { int[] selectedRows = table.getSelectedRows(); if (selectedRows.length != 0) { int response = JOptionPane.showConfirmDialog(ProxyApp.this, "Are you sure you want to delete " + selectedRows.length + " Transactions?", "Confirm Delete", JOptionPane.YES_NO_OPTION); if (response == JOptionPane.YES_OPTION) { int[] correctedRows = new int[selectedRows.length]; for (int i = selectedRows.length; --i >= 0;) { int row = selectedRows[i]; int index = (Integer) table.getValueAt(row, 0) - 1; correctedRows[i] = index; } Arrays.sort(correctedRows); for (int i = correctedRows.length; --i >= 0;) { int row = correctedRows[i]; Transaction transaction = model.getTransactionForIndex(row); if (transaction != null) { model.removeTransaction(transaction, row); isDirty = true; saveAction.setEnabled(isDirty && !stopAction.isEnabled()); } } } } } }); pm.add(item); table.add(pm); table.addMouseListener(new MouseAdapter() { boolean pressed = false; public void mouseClicked(MouseEvent e) { if (e.getClickCount() == 2) { Point p = e.getPoint(); int row = table.rowAtPoint(p); int index = (Integer) table.getValueAt(row, 0) - 1; Transaction transaction = model.getTransactionForIndex(index); if (transaction != null) { detailsTF.setText(transaction.toString()); detailsTF.setCaretPosition(0); detailsDialog.setVisible(true); } } } /** * @{inheritDoc */ @Override public void mousePressed(MouseEvent e) { if (e.isPopupTrigger()) { pressed = true; int[] selectedRows = table.getSelectedRows(); if (selectedRows.length != 0) { pm.show(e.getComponent(), e.getX(), e.getY()); } } } /** * @{inheritDoc */ @Override public void mouseReleased(MouseEvent e) { if (!pressed && e.isPopupTrigger()) { int[] selectedRows = table.getSelectedRows(); if (selectedRows.length != 0) { pm.show(e.getComponent(), e.getX(), e.getY()); } } } }); JScrollPane pane = new JScrollPane(table); frame.add(pane, BorderLayout.CENTER); JPanel panel = new JPanel(new BorderLayout()); JLabel label = new JLabel("Filter: "); panel.add(label, BorderLayout.WEST); final JLabel countLabel = new JLabel(" Count: 0 "); panel.add(countLabel, BorderLayout.EAST); final JTextField filterText = new JTextField(""); filterText.addKeyListener(new KeyAdapter() { public void keyTyped(KeyEvent e) { String text = filterText.getText(); if (text.length() == 0) { sorter.setRowFilter(null); } else { try { sorter.setRowFilter(RowFilter.regexFilter(text)); countLabel.setText(" Count: " + sorter.getViewRowCount() + " "); } catch (PatternSyntaxException pse) { System.err.println("Bad regex pattern"); } } } }); panel.add(filterText, BorderLayout.CENTER); frame.add(panel, BorderLayout.NORTH); return frame; }
From source file:edu.virginia.speclab.juxta.author.view.export.WebServiceExportDialog.java
private void onExportClicked() { File jxt = null;//w w w . j a v a 2 s . c om boolean errorHandled = false; try { // make sure all data has been specified String setName = this.nameEdit.getText(); if (setName.length() == 0) { JOptionPane.showMessageDialog(this.juxtaFrame, "Please enter an export name for this session", "Missing Data", JOptionPane.ERROR_MESSAGE); return; } // dump the session to a temporary jxt file // and send this to the web service. Note that the // false param on the save marks this as a temporary one // that does not alter the session itself jxt = File.createTempFile("export", ".jxt"); this.juxtaFrame.getSession().saveSessionForExport(jxt); final String desc = this.descriptionEdit.getText(); try { // do the export showStatusUI(); authenticateUser(); this.exportTaskId = this.wsClient.beginExport(jxt, setName, desc); } catch (Exception e) { // catch naming conflict errors and prompt to overwrite if (e.getMessage().contains("Conflict")) { int resp = JOptionPane.showConfirmDialog(this.juxtaFrame, "A comparison set with this name already exists. Overwrite it?", "Overwrite", JOptionPane.YES_NO_OPTION); if (resp == JOptionPane.YES_OPTION) { this.statusLabel.setText("Re-Exporting JXT"); this.exportTaskId = this.wsClient.beginExport(jxt, setName, desc, true); } else { errorHandled = true; showSetupUI(); return; } } else { RequestStatus status = new RequestStatus(Status.FAILED, e.getMessage()); displayStatus(status); return; } } // kick off a thread that will do the // status check requests. this.statusTask = this.scheduler.scheduleAtFixedRate(new Runnable() { public void run() { final WebServiceClient client = WebServiceExportDialog.this.wsClient; final String id = WebServiceExportDialog.this.exportTaskId; try { RequestStatus status = client.getExportStatus(id); displayStatus(status); if (status.isTerminated()) { WebServiceExportDialog.this.statusTask.cancel(false); } } catch (IOException e) { RequestStatus status = new RequestStatus(Status.FAILED, e.getMessage()); displayStatus(status); WebServiceExportDialog.this.statusTask.cancel(false); } } }, 2, 2, TimeUnit.SECONDS); } catch (Exception e) { if (errorHandled == false) { JOptionPane.showMessageDialog(this.juxtaFrame, "Unable to export session:\n " + e.getMessage(), "Failure", JOptionPane.ERROR_MESSAGE); showSetupUI(); } } finally { if (jxt != null) { jxt.delete(); } } }