Example usage for javax.swing JOptionPane OK_OPTION

List of usage examples for javax.swing JOptionPane OK_OPTION

Introduction

In this page you can find the example usage for javax.swing JOptionPane OK_OPTION.

Prototype

int OK_OPTION

To view the source code for javax.swing JOptionPane OK_OPTION.

Click Source Link

Document

Return value form class method if OK is chosen.

Usage

From source file:com.cch.aj.entryrecorder.frame.MainJFrame.java

private void btnBore1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnBore1ActionPerformed
    Boolean isSave = false;/*from   w ww . ja va2s  .c om*/
    String staff = "";
    String pass = "NO";
    String checker = "";
    if (this.currentEntry != null) {
        if (AppHelper.CheckTwoDigit(this.txtBore11.getText())
                && AppHelper.CheckTwoDigit(this.txtBore21.getText())
                && AppHelper.CheckTwoDigit(this.txtNeck1.getText())) {
            if (recordValidationService.Validate(currentEntry, RecordKey.THREAD_BORE1_2,
                    Float.parseFloat(this.txtBore11.getText()))
                    && recordValidationService.Validate(currentEntry, RecordKey.THREAD_BORE2_2,
                            Float.parseFloat(this.txtBore21.getText()))
                    && recordValidationService.Validate(currentEntry, RecordKey.THREAD_NECK_2,
                            Float.parseFloat(this.txtNeck1.getText()))) {
                isSave = true;

            } else {
                checker = JOptionPane.showInputDialog(this,
                        "the value is not within the range, please entry technician name.", "Warning",
                        JOptionPane.OK_OPTION);

                if (!checker.equals("")) {
                    isSave = true;
                }
            }
            staff = this.txtBoreStaff1.getText();
            this.txtBoreStaff1.setText("");
        } else {
            JOptionPane.showMessageDialog(this, "Please entry the valid number like (123.45).", "Warning",
                    JOptionPane.OK_OPTION);
        }

        if (isSave) {
            DefaultTableModel model = (DefaultTableModel) this.tblBore.getModel();
            Date now = new Date();
            String time = new SimpleDateFormat("HH:mm").format(now);
            Float valueBore1 = Float.parseFloat(this.txtBore11.getText());
            Float valueBore2 = Float.parseFloat(this.txtBore21.getText());
            Float valueNeck = Float.parseFloat(this.txtNeck1.getText());
            if (recordValidationService.Validate(currentEntry, RecordKey.THREAD_BORE1_2, valueBore1)) {
                pass = "YES";
            } else {
                pass = "NO(" + checker + ")";
            }
            model.addRow(new Object[] { time, RecordKey.THREAD_BORE1_2, valueBore1, pass, staff });
            UpdateEntryData(now, valueBore1, RecordKey.THREAD_BORE1_2, staff, pass, "");
            if (recordValidationService.Validate(currentEntry, RecordKey.THREAD_BORE2_2, valueBore2)) {
                pass = "YES";
            } else {
                pass = "NO(" + checker + ")";
            }
            model.addRow(new Object[] { time, RecordKey.THREAD_BORE2_2, valueBore2, pass, staff });
            UpdateEntryData(now, valueBore2, RecordKey.THREAD_BORE2_2, staff, pass, "");
            if (recordValidationService.Validate(currentEntry, RecordKey.THREAD_NECK_2, valueNeck)) {
                pass = "YES";
            } else {
                pass = "NO(" + checker + ")";
            }
            model.addRow(new Object[] { time, RecordKey.THREAD_NECK_2, valueNeck, pass, staff });
            UpdateEntryData(now, valueNeck, RecordKey.THREAD_NECK_2, staff, pass, "");

            ((AbstractTableModel) this.tblBore.getModel()).fireTableDataChanged();
            this.txtBore11.setText("");
            this.txtBore21.setText("");
            this.txtNeck1.setText("");
        }
    }
}

From source file:com.cch.aj.entryrecorder.frame.SettingsJFrame.java

private void btnProductNewActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnProductNewActionPerformed
    if (this.settingMouldId == 0) {
        JOptionPane.showMessageDialog(this, "Please select mould first.", "Warning", JOptionPane.OK_OPTION);
    } else {/*from  w  w w  .java 2 s. com*/
        int newId = this.productService.CreateEntity();
        if (this.settingMouldId != 0) {
            Product newProduct = (Product) this.productService.FindEntity(newId);
            newProduct.setMouldId(this.mouldService.FindEntity(this.settingMouldId));
            this.productService.UpdateEntity(newProduct);
        }
        UpdateTabProduct(newId);
    }
}

From source file:com.cch.aj.entryrecorder.frame.SettingsJFrame.java

private void btnCheckInsertActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCheckInsertActionPerformed
    if (!this.txtCheckDesc.getText().equals("")) {
        String desc = this.txtCheckDesc.getText();

        int checkId = this.checkitemService.CreateEntity();
        Checkitem check = this.checkitemService.FindEntity(checkId);
        check.setDescription(desc);/*from   w  ww.  j a v a  2  s  .c om*/
        List<Product> list = new ArrayList<Product>();
        list.add(this.settingProduct);
        check.setProductCollection(list);
        this.checkitemService.UpdateEntity(check);
        DefaultTableModel model = (DefaultTableModel) this.tblCheck.getModel();
        model.addRow(new Object[] { check.getId(), desc });
        this.txtCheckDesc.setText("");
    } else {
        JOptionPane.showMessageDialog(this, "please enter the valid data", "Warming", JOptionPane.OK_OPTION);
    }
}

From source file:lu.fisch.unimozer.Diagram.java

public void exportPNG() {
    selectClass(null);/*w ww. j a  v a  2  s  . c o m*/

    JFileChooser dlgSave = new JFileChooser("Export diagram as PNG ...");
    // propose name
    String uniName = directoryName.substring(directoryName.lastIndexOf('/') + 1).trim();
    dlgSave.setSelectedFile(new File(uniName));

    dlgSave.addChoosableFileFilter(new PNGFilter());
    int result = dlgSave.showSaveDialog(frame);
    if (result == JFileChooser.APPROVE_OPTION) {
        String filename = dlgSave.getSelectedFile().getAbsoluteFile().toString();
        if (!filename.substring(filename.length() - 4, filename.length()).toLowerCase().equals(".png")) {
            filename += ".png";
        }

        File file = new File(filename);
        BufferedImage bi = new BufferedImage(this.getWidth(), this.getHeight(), BufferedImage.TYPE_4BYTE_ABGR);
        paint(bi.getGraphics());
        try {
            ImageIO.write(bi, "png", file);
        } catch (Exception e) {
            JOptionPane.showOptionDialog(frame, "Error while saving the image!", "Error", JOptionPane.OK_OPTION,
                    JOptionPane.ERROR_MESSAGE, null, null, null);
        }
    }
}

From source file:com.openbravo.pos.sales.JRetailPanelTakeAway.java

private void printTicketGeneric(String sresourcename, RetailTicketInfo ticket, Object ticketext) {
    java.util.List<TicketLineConstructor> allLines = null;
    java.util.List<TicketLineConstructor> startallLines = new ArrayList<TicketLineConstructor>();
    int count = 0;
    com.openbravo.pos.printer.printer.ImageBillPrinter printer = new ImageBillPrinter();
    if (sresourcename.equals("Printer.Bill")) {
        allLines = getAllLines(ticket, ticketext);

    } else if (sresourcename.equals("Printer.NonChargableBill")) {
        allLines = getNonChargeableLines(ticket, ticketext);
    }// www  .  jav  a  2s  . c o m
    //try {
    //printer.print(allLines);
    //        try {
    int divideLines = allLines.size() / 48;
    int remainder = allLines.size() % 48;
    System.out.println("divideLines---" + divideLines + "--" + remainder);
    int value = 48;
    int k = 0;
    if (divideLines > 0) {
        for (int i = 0; i < divideLines; i++) {
            for (int j = k; j < value; j++) {

                startallLines.add(new TicketLineConstructor(allLines.get(j).getLine()));
                System.out.println("allLines.get(j).getLine()--" + allLines.get(j).getLine());
            }
            try {
                printer.print(startallLines);
            } catch (PrinterException ex) {
                Logger.getLogger(JRetailPanelTicket.class.getName()).log(Level.SEVERE, null, ex);
            }
            if (allLines.size() > 48) {
                try {
                    Thread.sleep(5000);
                } catch (InterruptedException ex) {
                    Logger.getLogger(JRetailPanelTicket.class.getName()).log(Level.SEVERE, null, ex);
                }
                int res = JOptionPane.showConfirmDialog(this,
                        AppLocal.getIntString("message.wannaPrintcontinue"),
                        AppLocal.getIntString("message.title"), JOptionPane.OK_OPTION,
                        JOptionPane.QUESTION_MESSAGE);
                if (res == JOptionPane.OK_OPTION) {
                    k = value;
                    value = value + 48;
                    startallLines = new ArrayList<TicketLineConstructor>();
                    System.out.println("startallLinest--" + startallLines.size());
                    startallLines.clear();
                } else {
                    break;
                }
            }

        }
    }
    System.out.println("value---" + value + k + "--" + remainder);
    if (remainder > 0) {
        startallLines = new ArrayList<TicketLineConstructor>();
        System.out.println("startallLinest--" + startallLines.size());
        startallLines.clear();
        for (int m = k; m < k + remainder; m++) {

            startallLines.add(new TicketLineConstructor(allLines.get(m).getLine()));
            System.out.println("allLines.get(j).getLine()--" + allLines.get(m).getLine());
        }
        try {
            printer.print(startallLines);
        } catch (PrinterException ex) {
            Logger.getLogger(JRetailPanelTicket.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
    //                        try {
    //                            printer.print(allLines);
    //
    //                        } catch (PrinterException ex) {
    //                            Logger.getLogger(JRetailPanelTakeAway.class.getName()).log(Level.SEVERE, null, ex);
    //                        }
}

From source file:net.technicpack.launcher.ui.InstallerFrame.java

protected void selectStandard() {
    File installDir = new File(standardInstallDir.getText());

    while (!installDir.exists()) {
        installDir = installDir.getParentFile();
    }/*from   w  ww .j  a v  a  2 s  .  c  o  m*/

    JFileChooser chooser = new JFileChooser(installDir);
    chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);

    int result = chooser.showOpenDialog(this);

    if (result == JFileChooser.APPROVE_OPTION) {
        if (chooser.getSelectedFile().listFiles().length > 0) {
            JOptionPane.showMessageDialog(this, resources.getString("modpackoptions.move.errortext"),
                    resources.getString("modpackoptions.move.errortitle"), JOptionPane.OK_OPTION);
            return;
        }

        standardInstallDir.setText(chooser.getSelectedFile().getAbsolutePath());
    }
}

From source file:nz.govt.natlib.ndha.manualdeposit.bulkupload.BulkUploadForm.java

public boolean confirm(final String message, final boolean useYesNo) {
    int optionType;
    if (useYesNo) {
        optionType = JOptionPane.YES_NO_OPTION;
    } else {/*from w  w  w .  j  a  va2  s.  c om*/
        optionType = JOptionPane.OK_CANCEL_OPTION;
    }
    return (JOptionPane.showConfirmDialog(this, message, "Please Confirm",
            optionType) == JOptionPane.OK_OPTION);
}

From source file:nz.govt.natlib.ndha.manualdeposit.login.Login.java

public boolean confirm(String message) {
    if (JOptionPane.showConfirmDialog(this, message, "Please Confirm",
            JOptionPane.OK_CANCEL_OPTION) == JOptionPane.OK_OPTION) {
        return true;
    } else {/* ww w .j  a va2 s.c  om*/
        return false;
    }
}

From source file:nz.govt.natlib.ndha.manualdeposit.ManualDepositMain.java

public boolean confirm(String message, boolean useYesNo) {
    int optionType;
    if (useYesNo) {
        optionType = JOptionPane.YES_NO_OPTION;
    } else {//from   w w  w.j  av a 2s  .  c om
        optionType = JOptionPane.OK_CANCEL_OPTION;
    }
    return (JOptionPane.showConfirmDialog(this, message, "Please Confirm",
            optionType) == JOptionPane.OK_OPTION);
}

From source file:openlr.mapviewer.coding.ui.SaveConfigButtonListener.java

/**
 * Checks if writing to the specified file is valid. If the target file
 * already exists the user is asked for confirmation to overwrite it. In
 * case of confirmation or if the file not yet exists {@code true} is
 * returned, otherwise {@code false}./*from   www .j  ava2 s.co  m*/
 * 
 * @param target
 *            The target file to check
 * @return whether it is valid to write to that file
 */
private boolean writePermitted(final File target) {

    boolean write = true;
    if (target.exists()) {

        int choice = JOptionPane.showConfirmDialog(codeOptionsDialog,
                "File " + target.getName() + " already exists. Do you really want to overwrite it?",
                "File already exists", JOptionPane.YES_NO_OPTION);

        if (choice != JOptionPane.OK_OPTION) {
            write = false;
        }
    }
    return write;
}