List of usage examples for javax.swing JOptionPane showInputDialog
public static String showInputDialog(Component parentComponent, Object message) throws HeadlessException
parentComponent
. From source file:fs.MainWindow.java
public void Correlation() { try {/*from ww w .java2s. c om*/ String features = JOptionPane.showInputDialog( "Select features" + " (columns) to calculate correlation coeficient:", "0 1 2"); if (features != null) { StringTokenizer s = new StringTokenizer(features); int nrfeatures = s.countTokens(); int[] selectedfeatures = new int[nrfeatures]; for (int n = 0; n < nrfeatures; n++) { selectedfeatures[n] = Integer.valueOf(s.nextToken()); } //correlation coeficient among classes or among features. if (jCB_HasLabels.isSelected()) { String[] titles = getClasses(); GenerateTable(MathRoutines.getCorrelationCoeficientClasses(Mo, selectedfeatures), "Correlation coeficients among classes", "Correlation coeficients among classes using " + "the average values of the features: " + features, titles); } else { String[] titles = new String[selectedfeatures.length]; for (int i = 0; i < selectedfeatures.length; i++) { titles[i] = String.valueOf(selectedfeatures[i]); } GenerateTable(MathRoutines.getCorrelationCoeficientFeatures(Mo, selectedfeatures), "Correlation coeficients among features", "Correlation coeficients among features: " + features, titles); } } } catch (Exception error) { throw new FSException("Error on select features to correlation" + " coeficient. " + error, false); } }
From source file:fs.MainWindow.java
public void ParallelPlot(boolean meanvaluesonly, boolean normalize) { try {//from w ww .ja v a 2 s. c om String strfeatures = JOptionPane .showInputDialog("Select features" + " (columns) to plot parallel coordinates:", "0 1 2"); if (strfeatures != null) { int[] features = null; if (strfeatures.isEmpty()) { //if is empty, include all features features = new int[columns - has_labels]; for (int i = 0; i < columns - has_labels; i++) { features[i] = i; } } else { StringTokenizer s = new StringTokenizer(strfeatures); features = ExtractIndices(s); } //find classes. int classes = fs.Main.maximumValue(Mo, 0, lines - 1, columns - 1, columns - 1) + 1; float[][] M = Preprocessing.copyMatrix(Mo); //normaliza os valores entre 0..1 dos features antes de plotar. if (normalize) { Preprocessing.ScaleColumn(M, 2, has_labels); //Preprocessing.ScaleRow(M, 2, has_labels); } if (meanvaluesonly) { Chart.PlotMeanParallelCoordinates("Parallel Coordinates" + " (Average Values)", "features", "values", M, classes, features, featurestitles, datatitles); } else { Chart.PlotParallelCoordinates("Parallel Coordinates", "features", "values", M, classes, features, featurestitles, datatitles); } } } catch (Exception error) { throw new FSException("Error on select features to plot parallel" + " coordinates. " + error, false); } }
From source file:com.peterbochs.PeterBochsDebugger.java
private void jSBButtonActionPerformed(ActionEvent evt) { if (jSBButton.getEventSource() != null) { long l = Long.parseLong(((JMenuItem) jSBButton.getEventSource()).getText()); sendCommand("sb " + l); Setting.getInstance().sbAddress.add(l); } else {/*w w w .j a v a 2s. co m*/ String s = JOptionPane.showInputDialog(this, "Please input cycle interval for next stop?"); if (s == null) { return; } try { long l = Long.parseLong(s); sendCommand("sb " + l); Setting.getInstance().sbAddress.add(l); } catch (Exception ex) { if (Global.debug) { ex.printStackTrace(); } } } for (int x = 0; x < Setting.getInstance().sbAddress.size() - 10; x++) { Setting.getInstance().sbAddress.remove(Setting.getInstance().sbAddress.toArray()[x]); } Setting.getInstance().save(); loadSBButton(); }
From source file:com.peterbochs.PeterBochsDebugger.java
private void jSBAButtonActionPerformed(ActionEvent evt) { if (jSBAButton.getEventSource() != null) { long l = Long.parseLong(((JMenuItem) jSBAButton.getEventSource()).getText()); sendCommand("sba " + l); Setting.getInstance().sbaAddress.add(l); } else {//from w ww . j a v a 2 s .c om String s = JOptionPane.showInputDialog(this, "Please input cycle interval for next stop?"); if (s == null) { return; } try { long l = Long.parseLong(s); sendCommand("sba " + l); Setting.getInstance().sbaAddress.add(l); } catch (Exception ex) { if (Global.debug) { ex.printStackTrace(); } } } for (int x = 0; x < Setting.getInstance().sbaAddress.size() - 10; x++) { Setting.getInstance().sbaAddress.remove(Setting.getInstance().sbaAddress.toArray()[x]); } Setting.getInstance().save(); loadSBAButton(); }
From source file:org.diyefi.openlogviewer.propertypanel.PropertiesPane.java
private JMenuBar createMenuBar() { final JMenuBar propMenuBar = new JMenuBar(); final JMenu options = new JMenu(labels.getString(Text.OPTIONS_MENU_NAME)); final JMenuItem addProperty = new JMenuItem(labels.getString(Text.OPTIONS_MENU_ITEM_ADD_PROPERTY_NAME)); final JMenuItem removeProperty = new JMenuItem( labels.getString(Text.OPTIONS_MENU_ITEM_REMOVE_PROPERTIES_NAME)); propMenuBar.add(options);/* w w w .j ava 2 s . c om*/ addProperty.addActionListener(new ActionListener() { @Override public void actionPerformed(final ActionEvent evt) { final String s = (String) JOptionPane.showInputDialog(rootPane, labels.getString(Text.ENTER_HEADER_FOR_PROPERTY)); if (StringUtils.isNotBlank(s)) { final SingleProperty newprop = new SingleProperty(); newprop.setHeader(s); addProperty(newprop); } } }); removeProperty.addActionListener(new ActionListener() { @Override public void actionPerformed(final ActionEvent evt) { removePropertyPanels(); } }); options.add(addProperty); options.add(removeProperty); return propMenuBar; }
From source file:org.hu.deezer.DeezerAction.java
@Override public void actionPerformed(ActionEvent e) { try {//from w w w . j a v a 2s.co m loadUserIdSettings(); if (userID.equals("")) { userID = JOptionPane.showInputDialog(null, "Please enter your Deezer ID."); System.setProperty("deezerID", userID); } HashMap<String, Long> playlists = getDeezerPlaylists( "https://api.deezer.com/user/" + userID + "/playlists"); String[] options = getArrayFromMap(playlists); String selected = (String) JOptionPane.showInputDialog(null, "Select a playlist", "Deezer playlists", JOptionPane.QUESTION_MESSAGE, null, options, options[1]); if (selected != null) { Long playlistId = playlists.get(selected); URLDisplayer.getDefault().showURL(new URL("http://www.deezer.com/playlist/" + playlistId)); } } catch (Exception eee) { eee.printStackTrace(); return;//nothing much to do } }
From source file:org.interreg.docexplore.management.manage.ManageComponent.java
public void importBook(final File file, final Book selected) { GuiUtils.blockUntilComplete(new ProgressRunnable() { float[] progress = { 0 }; BookExporter exporter = new BookExporter(); public void run() { File tmpDir = null;// w ww. j a v a 2s .c om try { tmpDir = new File(DocExploreTool.getHomeDir(), ".export-tmp"); if (tmpDir.exists()) FileUtils.deleteDirectory(tmpDir); tmpDir.mkdirs(); ZipUtils.unzip(file, tmpDir); DataLinkFS2Source source = new DataLinkFS2Source(tmpDir.getAbsolutePath()); DataLink fs2link = source.getDataLink(); final ManuscriptLink link = new ManuscriptLink(fs2link); Book remote = link.getBook(link.getLink().getAllBookIds().get(0)); Book merge = null; boolean cancel = false; if (selected != null && selected.getLastPageNumber() == remote.getLastPageNumber()) { int res = JOptionPane.showConfirmDialog(win, XMLResourceBundle.getBundledString("manageMergeMessage").replace("%name", selected.getName()), XMLResourceBundle.getBundledString("manageMergeLabel"), JOptionPane.YES_NO_CANCEL_OPTION); if (res == JOptionPane.CANCEL_OPTION) cancel = true; else if (res == JOptionPane.YES_OPTION) merge = selected; } if (!cancel && merge == null) { Book found = findTitle(remote.getName()); if (found != null && found != selected && found.getLastPageNumber() == remote.getLastPageNumber()) { int res = JOptionPane.showConfirmDialog(win, XMLResourceBundle.getBundledString("manageMergeMessage").replace("%name", found.getName()), XMLResourceBundle.getBundledString("manageMergeLabel"), JOptionPane.YES_NO_CANCEL_OPTION); if (res == JOptionPane.CANCEL_OPTION) cancel = true; else if (res == JOptionPane.YES_OPTION) merge = found; } } String newTitle = null; if (!cancel && merge == null) { String title = remote.getName(); while (findTitle(title) != null) if ((title = JOptionPane.showInputDialog(XMLResourceBundle .getBundledString("manageExistsMessage").replace("%name", title), title)) == null) { cancel = true; break; } newTitle = title; } if (!cancel) { if (merge == null) { Book imported = exporter.add(remote, win.getDocExploreLink(), null); if (newTitle != null) imported.setName(newTitle); } else exporter.merge(remote, merge, null); } link.getLink().release(); } catch (Exception e) { ErrorHandler.defaultHandler.submit(e); } if (tmpDir != null) try { FileUtils.deleteDirectory(tmpDir); } catch (Exception e) { ErrorHandler.defaultHandler.submit(e, true); } } public float getProgress() { return .5f * exporter.progress + .5f * progress[0]; } }, win); reload(); }
From source file:org.jbpm.bpel.tutorial.atm.terminal.LogOnAction.java
public void actionPerformed(ActionEvent event) { Map context = AtmTerminal.getContext(); AtmPanel atmPanel = (AtmPanel) context.get(AtmTerminal.PANEL); // capture customer name String customerName = JOptionPane.showInputDialog(atmPanel, "Name on card:"); if (customerName == null) return;/*from w ww . j a va 2 s . com*/ context.put(AtmTerminal.CUSTOMER, customerName); try { // log on customer FrontEnd atmFrontEnd = (FrontEnd) context.get(AtmTerminal.FRONT_END); int ticketNo = ((Integer) context.get(AtmTerminal.TICKET)).intValue(); atmFrontEnd.logOn(ticketNo, customerName); // update atm panel atmPanel.setMessage("Hi, " + customerName + ".\nWhat do you want to do today?"); atmPanel.clearActions(); atmPanel.addAction(new GetBalanceAction()); atmPanel.addAction(new DepositAction()); atmPanel.addAction(new WithdrawAction()); atmPanel.addAction(new LogOffAction()); atmPanel.setStatus(atmFrontEnd.status(ticketNo)); } catch (UnauthorizedAccess e) { log.debug("unauthorized access", e); atmPanel.setMessage("I could not fulfill your request.\n" + "Your access was not authorized."); } catch (RemoteException e) { log.error("remote operation failure", e); atmPanel.setMessage("Communication with the bank failed.\n" + "Please try again."); } }
From source file:org.kepler.gui.kar.ExportArchiveAction.java
/** * Check a single NamedObj for LSID, name, and SemanticType. * //from w w w .ja va2s . c o m * @param checkIfSemenaticallyAnnotated If is true, and entity has no * semantic annotations, user is warned, but not required, to add * annotations. * * @return Returns true if the export should continue */ protected boolean checkSingleObject(NamedObj entity, boolean checkIfSemenaticallyAnnotated) { // Make sure it has an LSID _savekar.checkNamedObjLSID(entity); if (entity instanceof ComponentEntity) { // Make sure it has a Name // Query the user for a name if needed try { _savekar.checkNamedObjName(entity); // FIXME: shouldn't really need this // LSID should be the unique identifier for the library /* * LibraryManager lm = LibraryManager.getInstance(); if (lm == * null || lm.componentNameInUse(entity.getName())) { throw new * NameDuplicationException(null, ""); } */ } catch (Exception e1) { // / TODO // / it might be good to just go through the usual saveAs route // here, but // / it's challenging since the frame closes and a new is opened // without // / returning a ref. Also the KAR system reopens everything // once done // / (which would result in two of the same workflow being // open). // /kgf = (KeplerGraphFrame) this._parent; // /kgf._saveAs(".xml"); // TODO very similar to code in RenameComponentEntityAction, // find a way to merge? String message = "Please enter a name"; if (!_karType.equals("")) { message += " for this " + _karType; } message += ": "; String warnMessage = "ERROR name cannot contain the < sign"; String newName = JOptionPane.showInputDialog(message, entity.getName()); if (newName == null) { // user hit the cancel button return false; } int lessThan = newName.indexOf("<"); if (lessThan >= 0) { JOptionPane.showMessageDialog(_parent, warnMessage, "Error", JOptionPane.ERROR_MESSAGE); return false; } try { RenameUtil.renameComponentEntity((ComponentEntity) entity, newName); _parent.setTitle(entity.getName()); setDefaultFileName(newName + ".kar"); } catch (Exception e) { e.printStackTrace(); JOptionPane.showMessageDialog(_parent, "A problem occured."); return false; } try { _savekar.checkNamedObjName(entity); } catch (Exception e2) { if (e2.getMessage().equals("Unnamed")) { // continue using the unnamed name } else { JOptionPane.showMessageDialog(_parent, "KAR contents must have a name."); // stop the export return false; } } } } // Check to see if it has at least one SemanticType // Ask the user if they want to add one if it doesn't if (checkIfSemenaticallyAnnotated && SMSServices.getActorSemanticTypes(entity).size() == 0) { String message = "In order for KAR item: " + entity.getName() + " to show up in an Ontology" + " it must contain at least one Semantic Type.\n" + " Would you like to add a Semantic Type? "; String title = "Add Semantic Types?"; int choice = JOptionPane.showConfirmDialog(_parent, message, title, JOptionPane.YES_NO_OPTION); if (choice == JOptionPane.YES_OPTION) { SemanticTypeEditor editor = new SemanticTypeEditor(_parent, entity); editor.setModal(true); editor.setVisible(true); } } return true; }
From source file:org.mbs3.juniuploader.gui.pnlFormVariables.java
private void btnAddGroupActionPerformed(ActionEvent evt) { if (evt.getSource() == this.btnAddGroup) { String returnVal = JOptionPane.showInputDialog(this, "What is the name of the new group:"); if (returnVal != null && !returnVal.equals("")) { FormPairGroup fpg = new FormPairGroup(returnVal); frmMain.formGroups.addElement(fpg); log.trace("btnAddGroupActionPerformed() added group " + fpg.getName()); log.trace(frmMain.formGroups.getSize() + " items now in groups model"); } else {//from ww w . j a v a 2 s .co m log.trace("New form group cancelled by user."); } } }