List of usage examples for javax.swing JOptionPane showInputDialog
public static String showInputDialog(Component parentComponent, Object message, String title, int messageType) throws HeadlessException
parentComponent
with the dialog having the title title
and message type messageType
. From source file:it.isislab.dmason.tools.batch.BatchWizard.java
private void checkError() { //controllo solo numeri non negativi String regex = "(\\d)+|((\\d)+\\.(\\d)+)"; if (textFieldA.isVisible()) { boolean checkA = true; while (checkA) { String dist = textFieldA.getText(); boolean validateDist = dist.matches(regex); if (!validateDist) { String newDist = JOptionPane.showInputDialog(null, "Insert a number", "Number Format Error", 0); textFieldA.setText(newDist); }/*from w w w .ja v a2s . co m*/ else { checkA = false; } } } if (textFieldB.isVisible()) { boolean checkB = true; while (checkB) { String dist = textFieldB.getText(); boolean validateDist = dist.matches(regex); if (!validateDist) { String newDist = JOptionPane.showInputDialog(null, "Insert a number", "Number Format Error", 0); textFieldB.setText(newDist); } else { checkB = false; } } } if (textFieldEndValue.isVisible()) { boolean checkEndValue = true; while (checkEndValue) { String dist = textFieldEndValue.getText(); boolean validateDist = dist.matches(regex); if (!validateDist) { String newDist = JOptionPane.showInputDialog(null, "Insert a number", "Number Format Error", 0); textFieldEndValue.setText(newDist); } else { checkEndValue = false; } } } if (textFieldIncrement.isVisible()) { boolean checkIncrement = true; while (checkIncrement) { String dist = textFieldIncrement.getText(); boolean validateDist = dist.matches(regex); if (!validateDist) { String newDist = JOptionPane.showInputDialog(null, "Insert a number", "Number Format Error", 0); textFieldIncrement.setText(newDist); } else { checkIncrement = false; } } } if (textFieldStartValue.isVisible()) { boolean checkStartValue = true; while (checkStartValue) { String dist = textFieldStartValue.getText(); boolean validateDist = dist.matches(regex); if (!validateDist) { String newDist = JOptionPane.showInputDialog(null, "Insert a number", "Number Format Error", 0); textFieldStartValue.setText(newDist); } else { checkStartValue = false; } } } if (textFieldValue.isVisible()) { boolean checkValue = true; while (checkValue) { String dist = textFieldValue.getText(); boolean validateDist = dist.matches(regex); if (!validateDist) { String newDist = JOptionPane.showInputDialog(null, "Insert a number", "Number Format Error", 0); textFieldValue.setText(newDist); } else { checkValue = false; } } } if (textFieldList.isVisible()) { boolean checkList = true; while (checkList) { String dist = textFieldList.getText(); boolean validateDist = dist.matches("(\\d)+|((\\d)+\\.(\\d)+)((,)(\\d)+|((\\d)+\\.(\\d)+))*"); if (!validateDist) { String newDist = JOptionPane.showInputDialog(null, "Insert comma separate number list", "Number Format Error", 0); textFieldList.setText(newDist); } else { checkList = false; } } } if (textFieldNumberOfValues.isVisible()) { boolean checkNumberOfValues = true; while (checkNumberOfValues) { String dist = textFieldNumberOfValues.getText(); boolean validateDist = dist.matches("(\\d)+"); if (!validateDist) { String newDist = JOptionPane.showInputDialog(null, "Insert a number", "Number Format Error", 0); textFieldNumberOfValues.setText(newDist); } else { checkNumberOfValues = false; } } } if (textFieldNumberOfWorkers.isVisible()) { boolean checkNumberOfWorkers = true; while (checkNumberOfWorkers) { String dist = textFieldNumberOfWorkers.getText(); boolean validateDist = dist.matches("(\\d)+"); if (!validateDist) { String newDist = JOptionPane.showInputDialog(null, "Insert a number", "Number Format Error", 0); textFieldNumberOfWorkers.setText(newDist); } else { checkNumberOfWorkers = false; } } } if (textFieldRuns.isVisible()) { boolean checkRuns = true; while (checkRuns) { String dist = textFieldRuns.getText(); boolean validateDist = dist.matches("(\\d)+"); if (!validateDist) { String newDist = JOptionPane.showInputDialog(null, "Insert a number", "Number Format Error", 0); textFieldRuns.setText(newDist); } else { checkRuns = false; } } } }
From source file:br.com.atmatech.sac.view.ViewPessoa.java
private void jTtempresaKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jTtempresaKeyPressed // TODO add your handling code here: int coluna = jTtempresa.getSelectedColumn(); if ((evt.getKeyCode() == KeyEvent.VK_F) && (coluna >= 0)) { if (evt.isControlDown()) { String text = JOptionPane.showInputDialog(this, "Pesquisa: " + jTtempresa.getColumnName(coluna), "PESQUISA", JOptionPane.WARNING_MESSAGE); if (text != null) { //DefaultTableModel tabela = (DefaultTableModel) jTtmodulo.getModel(); //final TableRowSorter<TableModel> sorter = new TableRowSorter<TableModel>(tabela); // jTtmodulo.setRowSorter(sorter); text = text.toUpperCase(); if (jTtempresa.getColumnName(coluna).equals("RAZAO")) { buscaPessoa("RAZAO", text); }//from w ww . j av a2s. c o m if (jTtempresa.getColumnName(coluna).equals("FANTASIA")) { buscaPessoa("FANTASIA", text); } if (jTtempresa.getColumnName(coluna).equals("CNPJ")) { buscaPessoa("CNPJ", text); } if (jTtempresa.getColumnName(coluna).equals("ENDERECO")) { buscaPessoa("ENDERECO", text); } } } } }
From source file:org.jets3t.apps.cockpit.Cockpit.java
/** * Adds a bucket not owned by the current S3 user to the bucket listing, after * prompting the user for the name of the bucket to add. * To be added in this way, the third-party bucket must be publicly available. * *//*w w w. j a va 2 s . c o m*/ private void addThirdPartyBucket() { try { String bucketName = JOptionPane.showInputDialog(ownerFrame, "Name for third-party bucket:", "Add a third-party bucket", JOptionPane.QUESTION_MESSAGE); if (bucketName != null) { if (s3ServiceMulti.getS3Service().isBucketAccessible(bucketName)) { S3Bucket thirdPartyBucket = new S3Bucket(bucketName); bucketTableModel.addBucket(thirdPartyBucket, false); } else { String message = "Unable to access third-party bucket: " + bucketName; log.error(message); ErrorDialog.showDialog(ownerFrame, this, message, null); } } } catch (RuntimeException e) { throw e; } catch (Exception e) { String message = "Unable to access third-party bucket"; log.error(message, e); ErrorDialog.showDialog(ownerFrame, this, message, e); } }
From source file:fi.hoski.remote.ui.Admin.java
private AnyDataObject chooseMember(String title) { // search a member String[] columns = Member.MODEL.getProperties(); String lastName = JOptionPane.showInputDialog(panel, TextUtil.getText(Member.SUKUNIMI) + "?", title, JOptionPane.QUESTION_MESSAGE); if (lastName == null) { return null; }/*from w ww. ja v a2s . c o m*/ lastName = Utils.convertName(lastName); List<AnyDataObject> memberList = dss.retrieve(Member.KIND, Member.SUKUNIMI, lastName, columns); DataObjectChooser<AnyDataObject> ec = new DataObjectChooser<AnyDataObject>(Member.MODEL, memberList, title, "CHOOSE"); ec.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); List<AnyDataObject> selected = ec.choose(); if (selected != null && selected.size() == 1) { return selected.get(0); } else { return null; } }
From source file:br.com.atmatech.sac.view.ViewAtendimento.java
private void atalhoBuscaCliente() { //if ((evt.getKeyCode() == KeyEvent.VK_F)) { // if (evt.isControlDown()) { String text = JOptionPane.showInputDialog(jDcliente, "Pesquisa: ", "PESQUISA", JOptionPane.WARNING_MESSAGE); if (text != null) { //DefaultTableModel tabela = (DefaultTableModel) jTtmodulo.getModel(); //final TableRowSorter<TableModel> sorter = new TableRowSorter<TableModel>(tabela); // jTtmodulo.setRowSorter(sorter); text = text.toUpperCase();/*from ww w.j a v a2s . co m*/ // if (jTtdcliente.getColumnName(coluna).equals("FANTASIA")) { // buscaCliente("FANTASIA", text, "FANTASIA"); // } // if (jTtdcliente.getColumnName(coluna).equals("RAZAO")) { // buscaCliente("RAZAO", text, "RAZAO"); // } // if (jTtdcliente.getColumnName(coluna).equals("CNPJ")) { // buscaCliente("CNPJ", text, "CNPJ"); // } // if (jTtdcliente.getColumnName(coluna).equals("CIDADE")) { // buscaCliente("DISTRITO", text, "DISTRITO"); // } // if (jTtdcliente.getColumnName(coluna).equals("ENDERECO")) { // buscaCliente("ENDERECO", text, "ENDERECO"); // } buscaCliente(text, "RAZAO"); } // } // } }
From source file:de.tor.tribes.ui.windows.DSWorkbenchMainFrame.java
public void doImport() { String dir = GlobalOptions.getProperty("screen.dir"); if (dir == null) { dir = "."; }/* w w w .j a v a 2s . c o m*/ JFileChooser chooser = null; try { chooser = new JFileChooser(dir); } catch (Exception e) { JOptionPaneHelper.showErrorBox(this, "Konnte Dateiauswahldialog nicht ffnen.\nMglicherweise verwendest du Windows Vista. Ist dies der Fall, beende DS Workbench, klicke mit der rechten Maustaste auf DSWorkbench.exe,\n" + "whle 'Eigenschaften' und deaktiviere dort unter 'Kompatibilitt' den Windows XP Kompatibilittsmodus.", "Fehler"); return; } chooser.setDialogTitle("Datei auswhlen"); chooser.setFileFilter(new javax.swing.filechooser.FileFilter() { @Override public boolean accept(File f) { return (f != null) && (f.isDirectory() || f.getName().endsWith(".xml")); } @Override public String getDescription() { return "*.xml"; } }); int ret = chooser.showOpenDialog(this); if (ret == JFileChooser.APPROVE_OPTION) { try { File f = chooser.getSelectedFile(); String file = f.getCanonicalPath(); if (!file.endsWith(".xml")) { file += ".xml"; } File target = new File(file); String extension = JOptionPane.showInputDialog(this, "Welche Kennzeichnung sollen importierte Plne und Tags erhalten?\n" + "Lass das Eingabefeld leer oder drcke 'Abbrechen', um sie unverndert zu importieren.", "Kennzeichnung festlegen", JOptionPane.INFORMATION_MESSAGE); if (extension != null && extension.length() > 0) { logger.debug("Using import extension '" + extension + "'"); } else { logger.debug("Using no import extension"); extension = null; } if (target.exists()) { //do import String message = performImport(target, extension); JOptionPaneHelper.showInformationBox(this, message, "Import"); } GlobalOptions.addProperty("screen.dir", target.getParent()); } catch (Exception e) { logger.error("Failed to import data", e); JOptionPaneHelper.showErrorBox(this, "Import fehlgeschlagen.", "Import"); } } }
From source file:com.monead.semantic.workbench.SemanticWorkbench.java
/** * Set the maximum number of individuals to display for each class in the tree * view of the model//from w ww . j av a 2s . co m */ private void setMaximumIndividualsPerClassInTree() { final String currentValue = properties .getProperty(ConfigurationProperty.MAX_INDIVIDUALS_PER_CLASS_IN_TREE.key(), "0"); final String maximumChildNodes = JOptionPane.showInputDialog(this, "Enter the maximum number of individuals to be displayed\n" + "under each class in the tree view of the model.\n\n" + "Enter the value 0 (zero) to allow all the individuals\n" + "to be shown.\n\n" + "The current setting is: " + currentValue, "Limit Individuals Displayed Per Class in the Tree View", JOptionPane.QUESTION_MESSAGE); if (maximumChildNodes != null && maximumChildNodes.trim().length() > 0) { try { final int maxNodes = Integer.parseInt(maximumChildNodes); if (maxNodes >= 0) { properties.setProperty(ConfigurationProperty.MAX_INDIVIDUALS_PER_CLASS_IN_TREE.key(), maxNodes + ""); } else { JOptionPane.showMessageDialog(this, "The value entered for the maximum number of individuals\n" + "was less than 0. The original setting is unchanged.", "Negative Value Entered", JOptionPane.ERROR_MESSAGE); } } catch (Throwable throwable) { JOptionPane.showMessageDialog(this, "The value entered for the maximum number of individuals\n" + "was not a number. The original setting is unchanged.", "Non-numeric Value Entered", JOptionPane.ERROR_MESSAGE); } } }
From source file:com.cch.aj.entryrecorder.frame.MainJFrame.java
private void btnWallActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnWallActionPerformed Boolean isSave = false;//from ww w . j a va 2 s . co m String staff = ""; String pass = "NO"; String checker = ""; if (this.currentEntry != null) { if (AppHelper.CheckTwoDigit(this.txtWallBase.getText()) && AppHelper.CheckTwoDigit(this.txtWallHandleBung.getText()) && AppHelper.CheckTwoDigit(this.txtWallClosure.getText()) && AppHelper.CheckTwoDigit(this.txtWallHandleLeft.getText()) && AppHelper.CheckTwoDigit(this.txtWallHandleRight.getText()) && AppHelper.CheckTwoDigit(this.txtWallUnderHandle.getText())) { if (recordValidationService.Validate(currentEntry, RecordKey.WALL_BASE, Float.parseFloat(this.txtWallBase.getText())) && recordValidationService.Validate(currentEntry, RecordKey.WALL_CLOSURE, Float.parseFloat(this.txtWallClosure.getText())) && recordValidationService.Validate(currentEntry, RecordKey.WALL_HANDLE_BUNG, Float.parseFloat(this.txtWallHandleBung.getText())) && recordValidationService.Validate(currentEntry, RecordKey.WALL_HANDLE_LEFT, Float.parseFloat(this.txtWallHandleLeft.getText())) && recordValidationService.Validate(currentEntry, RecordKey.WALL_HANDLE_RIGHT, Float.parseFloat(this.txtWallHandleRight.getText())) && recordValidationService.Validate(currentEntry, RecordKey.WALL_UNDER_HANDLE, Float.parseFloat(this.txtWallUnderHandle.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.txtWallStaff.getText(); this.txtWallStaff.setText(""); } else { JOptionPane.showMessageDialog(this, "Please entry the valid number like (123.45).", "Warning", JOptionPane.OK_OPTION); } if (isSave) { DefaultTableModel model = (DefaultTableModel) this.tblWall.getModel(); Date now = new Date(); String time = new SimpleDateFormat("HH:mm").format(now); Float valueUnderHandle = Float.parseFloat(this.txtWallUnderHandle.getText()); Float valueBase = Float.parseFloat(this.txtWallBase.getText()); Float valueClosure = Float.parseFloat(this.txtWallClosure.getText()); Float valueHandleBung = Float.parseFloat(this.txtWallHandleBung.getText()); Float valueHandleLeft = Float.parseFloat(this.txtWallHandleLeft.getText()); Float valueHandleRight = Float.parseFloat(this.txtWallHandleRight.getText()); if (recordValidationService.Validate(currentEntry, RecordKey.WALL_UNDER_HANDLE, Float.parseFloat(this.txtWallUnderHandle.getText()))) { pass = "YES"; } else { pass = "NO(" + checker + ")"; } model.addRow(new Object[] { time, RecordKey.WALL_UNDER_HANDLE, valueUnderHandle, pass, staff }); UpdateEntryData(now, valueUnderHandle, RecordKey.WALL_UNDER_HANDLE, staff, pass, ""); if (recordValidationService.Validate(currentEntry, RecordKey.WALL_BASE, Float.parseFloat(this.txtWallBase.getText()))) { pass = "YES"; } else { pass = "NO(" + checker + ")"; } model.addRow(new Object[] { time, RecordKey.WALL_BASE, valueBase, "YES", staff }); UpdateEntryData(now, valueBase, RecordKey.WALL_BASE, staff, pass, ""); if (recordValidationService.Validate(currentEntry, RecordKey.WALL_CLOSURE, Float.parseFloat(this.txtWallClosure.getText()))) { pass = "YES"; } else { pass = "NO(" + checker + ")"; } model.addRow(new Object[] { time, RecordKey.WALL_CLOSURE, valueClosure, pass, staff }); UpdateEntryData(now, valueClosure, RecordKey.WALL_CLOSURE, staff, pass, ""); if (recordValidationService.Validate(currentEntry, RecordKey.WALL_HANDLE_BUNG, Float.parseFloat(this.txtWallHandleBung.getText()))) { pass = "YES"; } else { pass = "NO(" + checker + ")"; } model.addRow(new Object[] { time, RecordKey.WALL_HANDLE_BUNG, valueHandleBung, pass, staff }); UpdateEntryData(now, valueHandleBung, RecordKey.WALL_HANDLE_BUNG, staff, pass, ""); if (recordValidationService.Validate(currentEntry, RecordKey.WALL_HANDLE_LEFT, Float.parseFloat(this.txtWallHandleLeft.getText()))) { pass = "YES"; } else { pass = "NO(" + checker + ")"; } model.addRow(new Object[] { time, RecordKey.WALL_HANDLE_LEFT, valueHandleLeft, pass, staff }); UpdateEntryData(now, valueHandleLeft, RecordKey.WALL_HANDLE_LEFT, staff, pass, ""); if (recordValidationService.Validate(currentEntry, RecordKey.WALL_HANDLE_RIGHT, Float.parseFloat(this.txtWallHandleRight.getText()))) { pass = "YES"; } else { pass = "NO(" + checker + ")"; } model.addRow(new Object[] { time, RecordKey.WALL_HANDLE_RIGHT, valueHandleRight, pass, staff }); UpdateEntryData(now, valueHandleRight, RecordKey.WALL_HANDLE_RIGHT, staff, pass, ""); ((AbstractTableModel) this.tblWall.getModel()).fireTableDataChanged(); this.txtWallUnderHandle.setText(""); this.txtWallBase.setText(""); this.txtWallClosure.setText(""); this.txtWallHandleBung.setText(""); this.txtWallHandleLeft.setText(""); this.txtWallHandleRight.setText(""); } } }
From source file:com.cch.aj.entryrecorder.frame.MainJFrame.java
private void btnTapActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnTapActionPerformed Boolean isSave = false;/* w ww .j ava 2s .c o m*/ String staff = ""; String pass = "NO"; if (this.currentEntry != null) { if (this.cbTap.getSelectedIndex() != 0) { if (recordValidationService.Validate(currentEntry, RecordKey.TAP_POSITION, (float) this.cbTap.getSelectedIndex())) { isSave = true; pass = "YES"; } else { String checker = JOptionPane.showInputDialog(this, "the value is not within the range, please entry technician name.", "Warning", JOptionPane.OK_OPTION); pass = "NO(" + checker + ")"; if (!checker.equals("")) { isSave = true; } } staff = txtTapStaff.getText(); this.txtTapStaff.setText(""); } else { JOptionPane.showMessageDialog(this, "Please select the tap position.", "Warning", JOptionPane.OK_OPTION); } if (isSave) { DefaultTableModel model = (DefaultTableModel) this.tblTap.getModel(); Date now = new Date(); String time = new SimpleDateFormat("HH:mm").format(now); Float value = (float) this.cbTap.getSelectedIndex(); String stringValue = this.cbTap.getSelectedItem().toString(); model.addRow(new Object[] { time, stringValue, pass, staff }); ((AbstractTableModel) this.tblTap.getModel()).fireTableDataChanged(); datasetTap.addValue(value, "Tap", time); this.cbTap.setSelectedIndex(0); UpdateEntryData(now, value, RecordKey.TAP_POSITION, staff, pass, stringValue); } } }
From source file:com.cch.aj.entryrecorder.frame.MainJFrame.java
private void btnBoreActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnBoreActionPerformed Boolean isSave = false;//from www . j a va 2 s. c o m String staff = ""; String pass = "NO"; String checker = ""; if (this.currentEntry != null) { if (AppHelper.CheckTwoDigit(this.txtBore1.getText()) && AppHelper.CheckTwoDigit(this.txtBore2.getText()) && AppHelper.CheckTwoDigit(this.txtNeck.getText())) { if (recordValidationService.Validate(currentEntry, RecordKey.THREAD_BORE1, Float.parseFloat(this.txtBore1.getText())) && recordValidationService.Validate(currentEntry, RecordKey.THREAD_BORE2, Float.parseFloat(this.txtBore2.getText())) && recordValidationService.Validate(currentEntry, RecordKey.THREAD_NECK, Float.parseFloat(this.txtNeck.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.txtBoreStaff.getText(); this.txtBoreStaff.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.txtBore1.getText()); Float valueBore2 = Float.parseFloat(this.txtBore2.getText()); Float valueNeck = Float.parseFloat(this.txtNeck.getText()); if (recordValidationService.Validate(currentEntry, RecordKey.THREAD_BORE1, valueBore1)) { pass = "YES"; } else { pass = "NO(" + checker + ")"; } model.addRow(new Object[] { time, RecordKey.THREAD_BORE1, valueBore1, pass, staff }); UpdateEntryData(now, valueBore1, RecordKey.THREAD_BORE1, staff, pass, ""); if (recordValidationService.Validate(currentEntry, RecordKey.THREAD_BORE2, valueBore2)) { pass = "YES"; } else { pass = "NO(" + checker + ")"; } model.addRow(new Object[] { time, RecordKey.THREAD_BORE2, valueBore2, pass, staff }); UpdateEntryData(now, valueBore2, RecordKey.THREAD_BORE2, staff, pass, ""); if (recordValidationService.Validate(currentEntry, RecordKey.THREAD_NECK, valueNeck)) { pass = "YES"; } else { pass = "NO(" + checker + ")"; } model.addRow(new Object[] { time, RecordKey.THREAD_NECK, valueNeck, pass, staff }); UpdateEntryData(now, valueNeck, RecordKey.THREAD_NECK, staff, pass, ""); ((AbstractTableModel) this.tblBore.getModel()).fireTableDataChanged(); this.txtBore1.setText(""); this.txtBore2.setText(""); this.txtNeck.setText(""); // } } }