List of usage examples for javax.swing JOptionPane showInputDialog
public static String showInputDialog(Component parentComponent, Object message, Object initialSelectionValue)
parentComponent
. From source file:hermes.browser.components.ClasspathGroupTable.java
public void doRename() { final ClasspathGroupConfig config = getClasspathGroupTableModel().getRow(getSelectedRow()); final String name = JOptionPane.showInputDialog(HermesBrowser.getBrowser(), "New name:", config.getId()); if (!config.getId().equals(name)) { config.setId(name);/*from www .j a v a2s .com*/ dialog.setDirty(); } }
From source file:hermes.browser.components.ClasspathGroupTable.java
public void doAddGroup() { final String name = JOptionPane.showInputDialog(HermesBrowser.getBrowser(), "Classpath group name:", ""); if (!StringUtils.isEmpty(name)) { final ClasspathGroupConfig config = new ClasspathGroupConfig(); config.setId(name);/*from w ww .ja va 2 s . c o m*/ getClasspathGroupTableModel().addRow(config); expandRow(getClasspathGroupTableModel().getRowCount() - 1); } }
From source file:GUI.Control.java
public ArrayList<String> graf1() { JOptionPane.showMessageDialog(null, "Grfica: Meses donde ms personas se registran."); boolean error = true; while (error) { //validacion e ingreso del nombre del cliente String defecto = "2016"; anio = JOptionPane.showInputDialog(null, "Ingrese el Ao que le interese:", defecto); if (anio != null && anio.length() > 0) { error = false;// w ww . j a v a 2 s .c om } } ArrayList<String> numeros = new ArrayList(); ArrayList IDcliente = dbman.executeQuery("select id from client order by id"); for (int i = 0; i < IDcliente.size(); i++) { ArrayList cliente = (ArrayList) IDcliente.get(i); numeros.add((String) cliente.get(0)); } ArrayList<String> meses = new ArrayList(); for (int i = 0; i < numeros.size(); i++) { ArrayList data = dbman.executeQuery( "select extract(month from (Select c.joined from client c where c.id =" + numeros.get(i) + "and ((select extract(year from (select joined from client where id = " + numeros.get(i) + ")))=" + anio + ")));"); ArrayList temp = (ArrayList) data.get(0); if (temp.get(0) != null) { meses.add((String) temp.get(0)); } } //System.out.println(meses); ArrayList<String> x = new ArrayList(); for (int i = 1; i <= 12; i++) { x.add(String.valueOf(i)); } // System.out.println(x); ArrayList<String> y = new ArrayList(); int contador = 0; for (int i = 0; i < x.size(); i++) { for (int j = 0; j < meses.size(); j++) { if (x.get(i).equals(meses.get(j))) { contador = contador + 1; } } y.add(String.valueOf(contador)); contador = 0; } return y; }
From source file:com.hammurapi.jcapture.CaptureFrame.java
protected void capture() throws Exception { try {//from w ww. j a v a 2 s. c o m Thread.sleep(200); // For Ubuntu. } catch (InterruptedException ie) { // Ignore } BufferedImage screenShot = captureConfig.createScreenShot(null, null).call().getRegions().get(0).getImage() .getImage(); String prefix = getDatePrefix(); String defaultImageFormat = applet.getParameter("imageFormat"); if (defaultImageFormat == null || defaultImageFormat.trim().length() == 0) { defaultImageFormat = "PNG"; } final String defaultFileExtension = defaultImageFormat.toLowerCase(); final String fileName = JOptionPane.showInputDialog(CaptureFrame.this, "Upload as", applet.getParameter("pageName") + "-capture-" + prefix + "-" + nextCounter() + "." + defaultFileExtension); if (fileName != null) { try { ByteArrayOutputStream baos = new ByteArrayOutputStream(); int idx = fileName.lastIndexOf('.'); String imageFormat = idx == -1 ? defaultImageFormat : fileName.substring(idx + 1).toUpperCase(); ImageIO.write(screenShot, imageFormat, baos); final byte[] imageBytes = baos.toByteArray(); System.out.println("Image size: " + imageBytes.length); // Uploading SwingWorker<Boolean, Long> task = new SwingWorker<Boolean, Long>() { @Override protected Boolean doInBackground() throws Exception { System.out.println("Uploading in background"); try { HttpResponse iResponse = applet.post(CaptureFrame.this, new ByteArrayInputStream(imageBytes), imageBytes.length, fileName, "application/octet-stream"); System.out.println("Response status line: " + iResponse.getStatusLine()); if (iResponse.getStatusLine().getStatusCode() != HttpStatus.SC_OK) { errorMessage = iResponse.getStatusLine(); errorTitle = "Error saving image"; return false; } return true; } catch (Error e) { errorMessage = e.toString(); errorTitle = "Upload error"; e.printStackTrace(); return false; } } private Object errorMessage; private String errorTitle; protected void done() { try { if (get()) { JSObject window = JSObject.getWindow(applet); String toEval = "insertAtCarret('" + applet.getParameter("edid") + "','{{:" + fileName + "|}}')"; System.out.println("Evaluating: " + toEval); window.eval(toEval); CaptureFrame.this.setVisible(false); } else { JOptionPane.showMessageDialog(CaptureFrame.this, errorMessage, errorTitle, JOptionPane.ERROR_MESSAGE); } } catch (Exception e) { e.printStackTrace(); JOptionPane.showMessageDialog(CaptureFrame.this, e.toString(), "Exception", JOptionPane.ERROR_MESSAGE); } }; }; task.execute(); } catch (IOException ex) { JOptionPane.showMessageDialog(applet, ex.toString(), "Error saving image", JOptionPane.ERROR_MESSAGE); } } }
From source file:de.pavloff.spark4knime.jsnippet.ui.JarListPanel.java
@SuppressWarnings("null") private void onJarURLAdd() { DefaultListModel<String> model = (DefaultListModel<String>) m_addJarList.getModel(); Set<String> hash = new HashSet<>(Collections.list(model.elements())); String input = "knime://knime.workflow/example.jar"; boolean valid; do {//ww w . j a v a 2 s . co m input = JOptionPane.showInputDialog(this, "Enter a \"knime:\" URL to a JAR file", input); if (StringUtils.isEmpty(input)) { valid = true; } else { URL url; try { url = new URL(input); File file = FileUtil.getFileFromURL(url); CheckUtils.checkArgument(file != null, "Could not resolve to local file"); CheckUtils.checkArgument(file.exists(), "File does not exists; location resolved to\n%s", file.getAbsolutePath()); valid = true; } catch (MalformedURLException | IllegalArgumentException mfe) { JOptionPane.showMessageDialog(this, "Invalid URL\n" + mfe.getMessage(), "Error parsing URL", JOptionPane.ERROR_MESSAGE); valid = false; continue; } } } while (!valid); if (!StringUtils.isEmpty(input) && hash.add(input)) { model.addElement(input); } }
From source file:be.ac.ua.comp.scarletnebula.gui.windows.ServerPropertiesWindow.java
private Component getSingleVNCComponent(final Server server) { return new ChangeableLabel(getVNCRep(server), new Executable<JLabel>() { @Override/*from w w w . j a v a 2 s . c o m*/ public void run(final JLabel text) { final String result = JOptionPane.showInputDialog(ServerPropertiesWindow.this, "Enter the password you'd like to use to establish VNC connections to this server.", server.getVNCPassword()); if (result != null && !result.isEmpty()) { server.setVNCPassword(result); server.store(); text.setText(result); } } }); }
From source file:avoking.com.documentos.scheduler.startup.Main.java
public void nuevoArch() { String value = JOptionPane.showInputDialog(null, "Introduce el rol:", 30); if (value != null) if (!value.isEmpty()) { try { int testRol = Integer.parseInt(value); Object[] possibilities = { "RH", "MA", "PR", "SA", "DG", "DO", "QA", "AM", "AP", "GC", "LO", "DP", "SI" }; value = (String) JOptionPane.showInputDialog(null, "Introduce el rol:", "Configuracin inicial", JOptionPane.PLAIN_MESSAGE, null, possibilities, "SI"); pathsDocs();//from w ww . j av a 2 s . c o m saveProps(value, testRol); return; } catch (NumberFormatException ec) { JOptionPane.showMessageDialog(null, "El rol es incorrecto, cargando por defecto...", "Rol incorrecto", JOptionPane.WARNING_MESSAGE); } } nuevoArch(); }
From source file:com.floreantpos.bo.ui.explorer.MenuItemExplorer.java
private TransparentPanel createButtonPanel() { ExplorerButtonPanel explorerButton = new ExplorerButtonPanel(); JButton editButton = explorerButton.getEditButton(); JButton addButton = explorerButton.getAddButton(); JButton deleteButton = explorerButton.getDeleteButton(); JButton duplicateButton = new JButton(POSConstants.DUPLICATE); JButton updateStockAmount = new JButton(Messages.getString("MenuItemExplorer.6")); //$NON-NLS-1$ JButton btnChangeMenuGroup = new JButton("Change Menu Group"); JButton btnChangeOrderType = new JButton("Change Order Type"); updateStockAmount.addActionListener(new ActionListener() { @Override//from w ww . j a va2s. c om public void actionPerformed(ActionEvent e) { try { int index = table.getSelectedRow(); if (index < 0) { POSMessageDialog.showMessage(MenuItemExplorer.this, Messages.getString("MenuItemExplorer.7")); //$NON-NLS-1$ return; } MenuItem menuItem = tableModel.getRow(index); String amountString = JOptionPane.showInputDialog(MenuItemExplorer.this, Messages.getString("MenuItemExplorer.8"), menuItem.getStockAmount()); //$NON-NLS-1$ if (amountString == null || amountString.equals("")) { //$NON-NLS-1$ return; } double stockAmount = Double.parseDouble(amountString); if (stockAmount < 0) { POSMessageDialog.showError(MenuItemExplorer.this, Messages.getString("MenuItemExplorer.10")); //$NON-NLS-1$ return; } menuItem.setStockAmount(stockAmount); MenuItemDAO.getInstance().saveOrUpdate(menuItem); table.repaint(); } catch (NumberFormatException e1) { POSMessageDialog.showError(MenuItemExplorer.this, Messages.getString("MenuItemExplorer.11")); //$NON-NLS-1$ return; } catch (Exception e2) { BOMessageDialog.showError(MenuItemExplorer.this, POSConstants.ERROR_MESSAGE, e2); return; } } }); editButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { doEditSelectedMenuItem(); } }); addButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { try { MenuItem menuItem = new MenuItem(); Object group = cbGroup.getSelectedItem(); if (group instanceof MenuGroup) { menuItem.setParent((MenuGroup) group); } Object selectedType = cbOrderTypes.getSelectedItem(); if (selectedType instanceof OrderType) { List types = new ArrayList(); types.add((OrderType) selectedType); menuItem.setOrderTypeList(types); } MenuItemForm editor = new MenuItemForm(menuItem); BeanEditorDialog dialog = new BeanEditorDialog(POSUtil.getBackOfficeWindow(), editor); dialog.open(); if (dialog.isCanceled()) return; MenuItem foodItem = (MenuItem) editor.getBean(); tableModel.addRow(foodItem); } catch (Throwable x) { BOMessageDialog.showError(POSConstants.ERROR_MESSAGE, x); } } }); duplicateButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { try { int index = table.getSelectedRow(); if (index < 0) return; index = table.convertRowIndexToModel(index); MenuItem existingItem = tableModel.getRow(index); existingItem = MenuItemDAO.getInstance().initialize(existingItem); MenuItem newMenuItem = new MenuItem(); PropertyUtils.copyProperties(newMenuItem, existingItem); newMenuItem.setId(null); String newName = doDuplicateName(existingItem); newMenuItem.setName(newName); newMenuItem.setFractionalUnit(existingItem.isFractionalUnit()); newMenuItem.setDisableWhenStockAmountIsZero(existingItem.isDisableWhenStockAmountIsZero()); newMenuItem.setShowImageOnly(existingItem.isShowImageOnly()); MenuItemForm editor = new MenuItemForm(newMenuItem); BeanEditorDialog dialog = new BeanEditorDialog(POSUtil.getBackOfficeWindow(), editor); dialog.open(); if (dialog.isCanceled()) return; MenuItem foodItem = (MenuItem) editor.getBean(); tableModel.addRow(foodItem); table.getSelectionModel().addSelectionInterval(tableModel.getRowCount() - 1, tableModel.getRowCount() - 1); table.scrollRowToVisible(tableModel.getRowCount() - 1); } catch (Throwable x) { BOMessageDialog.showError(POSConstants.ERROR_MESSAGE, x); } } }); btnChangeMenuGroup.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { try { int[] rows = table.getSelectedRows(); if (rows.length < 1) return; MenuGroup group = getSelectedMenuGroup(null); if (group == null) return; List<MenuItem> menuItems = new ArrayList<>(); for (int i = 0; i < rows.length; i++) { int index = table.convertRowIndexToModel(rows[i]); MenuItem menuItem = tableModel.getRow(index); menuItem.setParent(group); menuItems.add(menuItem); } MenuItemDAO.getInstance().saveAll(menuItems); searchItem(); } catch (Throwable x) { BOMessageDialog.showError(POSConstants.ERROR_MESSAGE, x); } } }); btnChangeOrderType.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { try { int[] rows = table.getSelectedRows(); if (rows.length < 1) return; List<OrderType> orderTypes = getSelectedOrderTypes(new ArrayList<>()); if (orderTypes == null) return; List<MenuItem> menuItems = new ArrayList<>(); for (int i = 0; i < rows.length; i++) { int index = table.convertRowIndexToModel(rows[i]); MenuItem menuItem = tableModel.getRow(index); menuItem.setOrderTypeList(orderTypes); menuItems.add(menuItem); } MenuItemDAO.getInstance().saveAll(menuItems); searchItem(); } catch (Throwable x) { BOMessageDialog.showError(POSConstants.ERROR_MESSAGE, x); } } }); deleteButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { try { int index = table.getSelectedRow(); if (index < 0) return; index = table.convertRowIndexToModel(index); if (POSMessageDialog.showYesNoQuestionDialog(MenuItemExplorer.this, POSConstants.CONFIRM_DELETE, POSConstants.DELETE) != JOptionPane.YES_OPTION) { return; } MenuItem item = tableModel.getRow(index); MenuItemDAO foodItemDAO = new MenuItemDAO(); if (item.getDiscounts() != null && item.getDiscounts().size() > 0) { foodItemDAO.releaseParentAndDelete(item); } else { foodItemDAO.delete(item); } tableModel.removeRow(index); } catch (Throwable x) { BOMessageDialog.showError(POSConstants.ERROR_MESSAGE, x); } } }); TransparentPanel panel = new TransparentPanel(); panel.add(addButton); panel.add(editButton); panel.add(updateStockAmount); panel.add(deleteButton); panel.add(duplicateButton); panel.add(btnChangeMenuGroup); panel.add(btnChangeOrderType); return panel; }
From source file:br.org.acessobrasil.ases.ferramentas_de_reparo.vista.xhtml.PainelXHTML.java
public void actionPerformed(ActionEvent e) { String cmd = e.getActionCommand(); if (cmd == "Salvar") { salvaAlteracoes.salvar();//from w w w. ja v a 2s.co m textAreaSourceCode.coloreSource(); reavalia(textAreaSourceCode.getText()); } else if (cmd == "AbrirURL") { String url; url = JOptionPane.showInputDialog(this, GERAL.DIGITE_ENDERECO, "http://"); avaliaUrl(url); // JOptionPane.showMessageDialog(null, "Seu nome " + nome); } else if (cmd == "Abrir") { String a[] = { ".html", ".htm" }; G_File temp = new G_File(caminhoRecente.read(), a); if (temp.getFile() != null) { avaliaArq(temp); } } else if (cmd == "SaveAs") { // salvarComo(); //salvaAlteracoes.setUltimoPath(caminhoRecente.read()); salvaAlteracoes.salvarComo(); // avalia(); } else if (cmd == "Creditos") { new Creditos(); } else if (cmd == "Sair") { System.exit(0); } else if (cmd == "SelecionarTudo") { textAreaSourceCode.getTextPane().selectAll(); if (ferrXHTMLPanelNaoEditavel != null) { ferrXHTMLPanelNaoEditavel.textAreaSourceCode.getTextPane().selectAll(); } } else if (cmd == "Desfazer") { textAreaSourceCode.undo(); // boxCode.coloreSource(); // reavalia(boxCode.getText()); } else if (cmd == "AumentaFonte") { textAreaSourceCode.aumentaFontSize(); } else if (cmd == "DiminuiFonte") { textAreaSourceCode.diminuiFontSize(); } else if (cmd == "Contraste") { textAreaSourceCode.autoContraste(); reavalia(textAreaSourceCode.getText()); } else if (cmd == "Cancelar") { salvaAlteracoes.cancelar(); } }
From source file:br.org.acessobrasil.ases.ferramentas_de_reparo.vista.css.FerramentaCSSPanel.java
private void abrirUrl() { String url; url = JOptionPane.showInputDialog(this, GERAL.DIGITE_ENDERECO, "http://"); avaliaUrl(url); }