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:com.nikonhacker.gui.EmulatorUI.java
private void openDecodeDialog() { JTextField sourceFile = new JTextField(); JTextField destinationDir = new JTextField(); FileSelectionPanel sourceFileSelectionPanel = new FileSelectionPanel("Source file", sourceFile, false); sourceFileSelectionPanel.setFileFilter(".bin", "Firmware file (*.bin)"); final JComponent[] inputs = new JComponent[] { sourceFileSelectionPanel, new FileSelectionPanel("Destination dir", destinationDir, true) }; if (JOptionPane.OK_OPTION == JOptionPane.showOptionDialog(this, inputs, "Choose source file and destination dir", JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE, null, null, JOptionPane.DEFAULT_OPTION)) { try {//from w ww. j a v a2 s .c o m new FirmwareDecoder().decode(sourceFile.getText(), destinationDir.getText(), false); JOptionPane.showMessageDialog(this, "Decoding complete", "Done", JOptionPane.INFORMATION_MESSAGE); } catch (FirmwareFormatException e) { JOptionPane.showMessageDialog(this, e.getMessage() + "\nPlease see console for full stack trace", "Error decoding files", JOptionPane.ERROR_MESSAGE); e.printStackTrace(); } } }
From source file:ca.uviccscu.lp.server.main.MainFrame.java
private void jButton5ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton5ActionPerformed l.info("Hash action activated"); final ActionEvent ev = evt; if (!Shared.hashInProgress) { //final Game gg; if (jTable1.getSelectedRow() >= 0) { DefaultTableModel mdl = (DefaultTableModel) jTable1.getModel(); String name = (String) mdl.getValueAt(jTable1.getSelectedRow(), 0); if (name != null) { MainFrame.lockInterface(); SwingWorker worker = new SwingWorker<Void, Void>() { @Override/* ww w . java 2s.c o m*/ public Void doInBackground() { l.trace("Starting hashing"); MainFrame.lockInterface(); Shared.hashInProgress = true; int row = jTable1.getSelectedRow(); String game = (String) jTable1.getModel().getValueAt(row, 0); l.trace("Selection - row: " + row + " and name " + game); int status = GamelistStorage.getGame(game).gameStatus; if (status == 0) { File g = new File(GamelistStorage.getGame(game).gameAbsoluteFolderPath); File tp = new File(SettingsManager.getTorrentFolderPath() + GamelistStorage.getGame(game).gameName + ".torrent"); try { updateTask("Preparing to hash - wait!", true); updateProgressBar(0, 0, 0, "...", false, true); jButton5.setText("STOP"); //jButton5.setForeground(Color.RED); jButton5.setEnabled(true); jButton5.requestFocusInWindow(); MainFrame.setReportingActive(); GamelistStorage.getGame(game).gameStatus = 1; MainFrame.updateGameInterfaceFromStorage(); TOTorrent t = TrackerManager.createNewTorrent(g, tp, new HashingProgressListener(game)); TrackerManager.getCore().addTorrentToTracker(t, tp.getAbsolutePath(), g.getAbsolutePath()); GamelistStorage.getGame(game).gameStatus = 2; MainFrame.updateGameInterfaceFromStorage(); MainFrame.setReportingIdle(); } catch (Exception ex) { l.error("Torrent create failed: " + game, ex); } } else if (status == 1 || status == 2) { l.error("Game torrent already created"); int ans = JOptionPane.showConfirmDialog(null, "This game has already been hashed. Rehash?", "Hashing error", JOptionPane.OK_CANCEL_OPTION, JOptionPane.WARNING_MESSAGE); if (ans == JOptionPane.OK_OPTION) { GamelistStorage.getGame(game).gameStatus = 0; File tp = new File(Shared.workingDirectory + Shared.torrentStoreSubDirectory + "\\" + GamelistStorage.getGame(game).gameName + ".torrent"); FileUtils.deleteQuietly(tp); Shared.hashInProgress = false; jButton5ActionPerformed(ev); Shared.hashInProgress = true; } else { // } } else { l.error("Game status invalid - hashing aborted"); } return null; } @Override public void done() { MainFrame.setReportingIdle(); jButton5.setText("Hash selected"); //jButton5.setForeground(Color.WHITE); MainFrame.unlockInterface(); Shared.hashInProgress = false; MainFrame.updateGameInterfaceFromStorage(); } }; worker.execute(); } else { l.trace("Empty row - no action required"); } } } else { try { l.trace("Stopping current hashing"); TrackerManager.cancelNewTorrentCreation(); int row = jTable1.getSelectedRow(); String game = (String) jTable1.getModel().getValueAt(row, 0); GamelistStorage.getGame(game).gameStatus = 0; MainFrame.unlockInterface(); MainFrame.updateGameInterfaceFromStorage(); } catch (TOTorrentException ex) { l.info("Abort exception received as expected", ex); } catch (Exception ex) { l.error("Hash abort unexpected exception - abort failed"); } jButton5.setText("Hash selected"); jButton5.setForeground(Color.WHITE); } }
From source file:co.com.soinsoftware.hotelero.view.JFRoom.java
private void jbtCheckInActionPerformed(java.awt.event.ActionEvent evt) {// GEN-FIRST:event_jbtCheckInActionPerformed if (this.validateDataForSave()) { if (this.validateInitialDate(true, MSG_INITIAL_DATE_TO_CHECKIN) && this.validateFinalDate()) { final int confirmation = ViewUtils.showConfirmDialog(this, ViewUtils.MSG_SAVE_QUESTION, ViewUtils.TITLE_SAVED); if (confirmation == JOptionPane.OK_OPTION) { this.saveUserInformation(); final Company company = this.getSelectedCompany(); final Date initialDate = this.jdcInitialDate.getDate(); final Date finalDate = this.jdcFinalDate.getDate(); final String siteFrom = this.jtfSiteFrom.getText(); final String siteTo = this.jtfSiteTo.getText(); this.invoiceController.saveCheckIn(this.user, String.valueOf(this.roomName), initialDate, finalDate, siteFrom, siteTo, company); ViewUtils.showMessage(this, ViewUtils.MSG_SAVED, ViewUtils.TITLE_SAVED, JOptionPane.INFORMATION_MESSAGE); this.refresh(); }// w w w . j ava 2s . c om } } }
From source file:com.nikonhacker.gui.EmulatorUI.java
private void openEncodeDialog() { JTextField destinationFile = new JTextField(); JTextField sourceFile1 = new JTextField(); JTextField sourceFile2 = new JTextField(); FileSelectionPanel destinationFileSelectionPanel = new FileSelectionPanel("Destination file", destinationFile, false);/* w w w.j a v a 2s . c om*/ destinationFileSelectionPanel.setFileFilter(".bin", "Encoded firmware file (*.bin)"); FileSelectionPanel sourceFile1SelectionPanel = new FileSelectionPanel("Source file 1", sourceFile1, false); destinationFileSelectionPanel.setFileFilter("a*.bin", "Decoded A firmware file (a*.bin)"); FileSelectionPanel sourceFile2SelectionPanel = new FileSelectionPanel("Source file 2", sourceFile2, false); destinationFileSelectionPanel.setFileFilter("b*.bin", "Decoded B firmware file (b*.bin)"); final JComponent[] inputs = new JComponent[] { destinationFileSelectionPanel, sourceFile1SelectionPanel, sourceFile2SelectionPanel }; if (JOptionPane.OK_OPTION == JOptionPane.showOptionDialog(this, inputs, "Choose target encoded file and source files", JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE, null, null, JOptionPane.DEFAULT_OPTION)) { try { ArrayList<String> inputFilenames = new ArrayList<String>(); inputFilenames.add(sourceFile1.getText()); inputFilenames.add(sourceFile2.getText()); new FirmwareEncoder().encode(inputFilenames, destinationFile.getText()); JOptionPane.showMessageDialog(this, "Encoding complete", "Done", JOptionPane.INFORMATION_MESSAGE); } catch (FirmwareFormatException e) { JOptionPane.showMessageDialog(this, e.getMessage() + "\nPlease see console for full stack trace", "Error encoding files", JOptionPane.ERROR_MESSAGE); e.printStackTrace(); } } }
From source file:com.nikonhacker.gui.EmulatorUI.java
private void openDecodeNkldDialog() { JTextField sourceFile = new JTextField(); JTextField destinationFile = new JTextField(); FileSelectionPanel sourceFileSelectionPanel = new FileSelectionPanel("Source file", sourceFile, false); sourceFileSelectionPanel.setFileFilter("nkld*.bin", "Lens correction data file (nkld*.bin)"); final JComponent[] inputs = new JComponent[] { sourceFileSelectionPanel, new FileSelectionPanel("Destination file", destinationFile, true) }; if (JOptionPane.OK_OPTION == JOptionPane.showOptionDialog(this, inputs, "Choose source file and destination dir", JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE, null, null, JOptionPane.DEFAULT_OPTION)) { try {/* w ww . j a v a 2 s . c o m*/ new NkldDecoder().decode(sourceFile.getText(), destinationFile.getText(), false); JOptionPane .showMessageDialog( this, "Decoding complete.\nFile '" + new File(destinationFile.getText()).getAbsolutePath() + "' was created.", "Done", JOptionPane.INFORMATION_MESSAGE); } catch (FirmwareFormatException e) { JOptionPane.showMessageDialog(this, e.getMessage() + "\nPlease see console for full stack trace", "Error decoding files", JOptionPane.ERROR_MESSAGE); e.printStackTrace(); } } }
From source file:com.isti.traceview.common.TraceViewChartPanel.java
/** * Displays a dialog that allows the user to edit the properties for the current chart. * //www . j a v a 2 s .co m * @since 1.0.3 */ public void doEditChartProperties() { ChartEditor editor = ChartEditorManager.getChartEditor(this.chart); int result = JOptionPane.showConfirmDialog(this, editor, localizationResources.getString("Chart_Properties"), JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE); if (result == JOptionPane.OK_OPTION) { editor.updateChart(this.chart); } }
From source file:cz.muni.fi.pv168.MainForm.java
private void jMenuItem19ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem19ActionPerformed String stringID = JOptionPane.showInputDialog("ID"); try {/*from ww w .ja va 2s.c o m*/ long id = Long.parseLong(stringID); for (Car c : ((CarsTableModel) carTable.getModel()).getCars()) { if (c.getID() == id) { new CarSwingWorker(CarsActions.REMOVE_CAR, c).execute(); return; } } } catch (NumberFormatException ex) { JOptionPane.showConfirmDialog(jMenu1, ("ID " + localization.getString("must_be_number")), localization.getString("invalid_input"), JOptionPane.OK_OPTION, JOptionPane.ERROR_MESSAGE); } }
From source file:cfa.vo.sed.science.stacker.SedStackerFrame.java
private void addButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_addButtonActionPerformed // TODO: remove this when I add "Load From File" option in the AddSedsFrame. if (manager.getSeds().isEmpty()) { NarrowOptionPane.showMessageDialog(this, "There are no open SEDs. Create SEDs using the SED Builder first.", "Error: No Open SEDs", JOptionPane.OK_OPTION); return;//from w ww .java2s .c om } if (addSedsFrame == null) { addSedsFrame = new AddSedsFrame(manager, selectedStack, sedsTable, this); ws.addFrame(addSedsFrame); } addSedsFrame.updateSeds(selectedStack); GUIUtils.moveToFront(addSedsFrame); }
From source file:cz.muni.fi.pv168.MainForm.java
private void jMenuItem20ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem20ActionPerformed String stringID = JOptionPane.showInputDialog("ID"); try {//w ww . ja v a2 s . c o m long id = Long.parseLong(stringID); for (Customer c : ((CustomersTableModel) customerTable.getModel()).getCustomers()) { if (c.getID() == id) { new CustomerSwingWorker(CustomersActions.REMOVE_CUSTOMER, c).execute(); return; } } } catch (NumberFormatException ex) { JOptionPane.showConfirmDialog(jMenu1, ("ID " + localization.getString("must_be_number")), localization.getString("invalid_input"), JOptionPane.OK_OPTION, JOptionPane.ERROR_MESSAGE); } }
From source file:cz.muni.fi.pv168.MainForm.java
private void jMenuItem21ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem21ActionPerformed String stringID = JOptionPane.showInputDialog("ID"); try {/*from w w w .j a v a 2 s. co m*/ long id = Long.parseLong(stringID); for (Rent r : ((RentsTableModel) rentTable.getModel()).getRents()) { if (r.getID() == id) { new RentalSwingWorker(RentsActions.REMOVE_RENT, r).execute(); return; } } } catch (NumberFormatException ex) { JOptionPane.showConfirmDialog(jMenu1, ("ID " + localization.getString("must_be_number")), localization.getString("invalid_input"), JOptionPane.OK_OPTION, JOptionPane.ERROR_MESSAGE); } }