List of usage examples for javax.swing JOptionPane JOptionPane
public JOptionPane(Object message, int messageType, int optionType)
JOptionPane
to display a message with the specified message type and options. From source file:com.ga.forms.DailyLogAddUI.java
private void checkInOutButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_checkInOutButtonActionPerformed DailyLogRecord log = new DailyLogRecord(); if (DailyLogAddUI.checkIn && !DailyLogAddUI.breakDone) { args = new HashMap(); DailyLogAddUI.breakDone = true;/*from www. ja va 2 s .co m*/ args.put("checked-in", Boolean.toString(DailyLogAddUI.checkIn)); args.put("had-break", Boolean.toString(DailyLogAddUI.breakDone)); args.put("checked-out", Boolean.toString(DailyLogAddUI.checkOut)); if (yesRdButton.isSelected() == true) { this.timeOnBreak = "00:30"; } else if (customRdButton.isSelected() == true) { this.timeOnBreak = customBreakTimeTextField.getText(); } else { this.timeOnBreak = "00:00"; } log.setDailyLogRecord(dateDisplayLbl.getText(), dayDisplayLbl.getText(), checkInTimeCombo.getSelectedItem().toString(), "", this.timeOnBreak, "", "", "", args); doc = (DBObject) JSON.parse(log.getDailyLogRecord().toString()); args.clear(); args.put("date", dateDisplayLbl.getText()); log.updateRecord(doc, args); } else if (DailyLogAddUI.checkIn && DailyLogAddUI.breakDone && !DailyLogAddUI.checkOut) { args = new HashMap(); DailyLogAddUI.checkOut = true; args.put("checked-in", Boolean.toString(DailyLogAddUI.checkIn)); args.put("had-break", Boolean.toString(DailyLogAddUI.breakDone)); args.put("checked-out", Boolean.toString(DailyLogAddUI.checkOut)); DailyLogDuration durationAgent = new DailyLogDuration(); durationAgent.calculateCurrentDuration(checkInTimeCombo.getSelectedItem().toString(), this.timeOnBreak, checkOutTimeCombo.getSelectedItem().toString()); this.duration = durationAgent.getCurrentDuration(); JFrame parent = new JFrame(); JOptionPane optionPane = new JOptionPane("Duration: " + this.duration + "\n\nDo you want to Check Out?", JOptionPane.QUESTION_MESSAGE, JOptionPane.YES_NO_OPTION); JDialog msgDialog = optionPane.createDialog(parent, "DLM"); msgDialog.setVisible(true); if (optionPane.getValue().equals(0)) { int hours = Integer.parseInt(this.duration.split(":")[0]); int minutes = Integer.parseInt(this.duration.split(":")[1]); if (hours < 9) { durationAgent.calculateUnderTime(this.duration); this.underTime = durationAgent.getUnderTime(); this.overTime = "00:00"; } else if (hours >= 9 && minutes > 0 && minutes < 60) { this.underTime = "00:00"; durationAgent.calculateOverTime(this.duration); this.overTime = durationAgent.getOverTime(); } else { this.underTime = "00:00"; this.overTime = "00:00"; } log.setDailyLogRecord(dateDisplayLbl.getText(), dayDisplayLbl.getText(), checkInTimeCombo.getSelectedItem().toString(), checkOutTimeCombo.getSelectedItem().toString(), this.timeOnBreak, this.duration, this.underTime, this.overTime, args); doc = (DBObject) JSON.parse(log.getDailyLogRecord().toString()); args.clear(); args.put("date", dateDisplayLbl.getText()); log.updateRecord(doc, args); } else { msgDialog.dispose(); } } else { args = new HashMap(); DailyLogAddUI.checkIn = true; args.put("checked-in", Boolean.toString(DailyLogAddUI.checkIn)); args.put("had-break", Boolean.toString(DailyLogAddUI.breakDone)); args.put("checked-out", Boolean.toString(DailyLogAddUI.checkOut)); log.setDailyLogRecord(dateDisplayLbl.getText(), dayDisplayLbl.getText(), checkInTimeCombo.getSelectedItem().toString(), "", "", "", "", "", args); doc = (DBObject) JSON.parse(log.getDailyLogRecord().toString()); log.insertRecord(doc); } }
From source file:net.rptools.maptool.client.functions.InputFunction.java
@Override public Object childEvaluate(Parser parser, String functionName, List<Object> parameters) throws EvaluationException, ParserException { // Extract the list of specifier strings from the parameters // "name | value | prompt | inputType | options" List<String> varStrings = new ArrayList<String>(); for (Object param : parameters) { String paramStr = (String) param; if (StringUtils.isEmpty(paramStr)) { continue; }/*w w w.jav a2 s .c o m*/ // Multiple vars can be packed into a string, separated by "##" List<String> substrings = new ArrayList<String>(); StrListFunctions.parse(paramStr, substrings, "##"); for (String varString : substrings) { if (StringUtils.isEmpty(paramStr)) { continue; } varStrings.add(varString); } } // Create VarSpec objects from each variable's specifier string List<VarSpec> varSpecs = new ArrayList<VarSpec>(); for (String specifier : varStrings) { VarSpec vs; try { vs = new VarSpec(specifier); } catch (VarSpec.SpecifierException se) { throw new ParameterException(se.msg); } catch (InputType.OptionException oe) { throw new ParameterException(I18N.getText("macro.function.input.invalidOptionType", oe.key, oe.value, oe.type, specifier)); } varSpecs.add(vs); } // Check if any variables were defined if (varSpecs.isEmpty()) return BigDecimal.ONE; // No work to do, so treat it as a successful invocation. // UI step 1 - First, see if a token is in context. VariableResolver varRes = parser.getVariableResolver(); Token tokenInContext = null; if (varRes instanceof MapToolVariableResolver) { tokenInContext = ((MapToolVariableResolver) varRes).getTokenInContext(); } String dialogTitle = "Input Values"; if (tokenInContext != null) { String name = tokenInContext.getName(), gm_name = tokenInContext.getGMName(); boolean isGM = MapTool.getPlayer().isGM(); String extra = ""; if (isGM && gm_name != null && gm_name.compareTo("") != 0) extra = " for " + gm_name; else if (name != null && name.compareTo("") != 0) extra = " for " + name; dialogTitle = dialogTitle + extra; } // UI step 2 - build the panel with the input fields InputPanel ip = new InputPanel(varSpecs); // Calculate the height // TODO: remove this workaround int screenHeight = Toolkit.getDefaultToolkit().getScreenSize().height; int maxHeight = screenHeight * 3 / 4; Dimension ipPreferredDim = ip.getPreferredSize(); if (maxHeight < ipPreferredDim.height) { ip.modifyMaxHeightBy(maxHeight - ipPreferredDim.height); } // UI step 3 - show the dialog JOptionPane jop = new JOptionPane(ip, JOptionPane.PLAIN_MESSAGE, JOptionPane.OK_CANCEL_OPTION); JDialog dlg = jop.createDialog(MapTool.getFrame(), dialogTitle); // Set up callbacks needed for desired runtime behavior dlg.addComponentListener(new FixupComponentAdapter(ip)); dlg.setVisible(true); int dlgResult = JOptionPane.CLOSED_OPTION; try { dlgResult = (Integer) jop.getValue(); } catch (NullPointerException npe) { } dlg.dispose(); if (dlgResult == JOptionPane.CANCEL_OPTION || dlgResult == JOptionPane.CLOSED_OPTION) return BigDecimal.ZERO; // Finally, assign values from the dialog box to the variables for (ColumnPanel cp : ip.columnPanels) { List<VarSpec> panelVars = cp.varSpecs; List<JComponent> panelControls = cp.inputFields; int numPanelVars = panelVars.size(); StringBuilder allAssignments = new StringBuilder(); // holds all values assigned in this tab for (int varCount = 0; varCount < numPanelVars; varCount++) { VarSpec vs = panelVars.get(varCount); JComponent comp = panelControls.get(varCount); String newValue = null; switch (vs.inputType) { case TEXT: { newValue = ((JTextField) comp).getText(); break; } case LIST: { Integer index = ((JComboBox) comp).getSelectedIndex(); if (vs.optionValues.optionEquals("VALUE", "STRING")) { newValue = vs.valueList.get(index); } else { // default is "NUMBER" newValue = index.toString(); } break; } case CHECK: { Integer value = ((JCheckBox) comp).isSelected() ? 1 : 0; newValue = value.toString(); break; } case RADIO: { // This code assumes that the Box container returns components // in the same order that they were added. Component[] comps = ((Box) comp).getComponents(); int componentCount = 0; Integer index = 0; for (Component c : comps) { if (c instanceof JRadioButton) { JRadioButton radio = (JRadioButton) c; if (radio.isSelected()) index = componentCount; } componentCount++; } if (vs.optionValues.optionEquals("VALUE", "STRING")) { newValue = vs.valueList.get(index); } else { // default is "NUMBER" newValue = index.toString(); } break; } case LABEL: { newValue = null; // The variable name is ignored and not set. break; } case PROPS: { // Read out and assign all the subvariables. // The overall return value is a property string (as in StrPropFunctions.java) with all the new settings. Component[] comps = ((JPanel) comp).getComponents(); StringBuilder sb = new StringBuilder(); int setVars = 0; // "NONE", no assignments made if (vs.optionValues.optionEquals("SETVARS", "SUFFIXED")) setVars = 1; if (vs.optionValues.optionEquals("SETVARS", "UNSUFFIXED")) setVars = 2; if (vs.optionValues.optionEquals("SETVARS", "TRUE")) setVars = 2; // for backward compatibility for (int compCount = 0; compCount < comps.length; compCount += 2) { String key = ((JLabel) comps[compCount]).getText().split("\\:")[0]; // strip trailing colon String value = ((JTextField) comps[compCount + 1]).getText(); sb.append(key); sb.append("="); sb.append(value); sb.append(" ; "); switch (setVars) { case 0: // Do nothing break; case 1: parser.setVariable(key + "_", value); break; case 2: parser.setVariable(key, value); break; } } newValue = sb.toString(); break; } default: // should never happen newValue = null; break; } // Set the variable to the value we got from the dialog box. if (newValue != null) { parser.setVariable(vs.name, newValue.trim()); allAssignments.append(vs.name + "=" + newValue.trim() + " ## "); } } if (cp.tabVarSpec != null) { parser.setVariable(cp.tabVarSpec.name, allAssignments.toString()); } } return BigDecimal.ONE; // success // for debugging: //return debugOutput(varSpecs); }
From source file:org.nuclos.client.ui.collect.Chart.java
private void actionCommandShow() { final JOptionPane optpn = new JOptionPane(subform, JOptionPane.PLAIN_MESSAGE, JOptionPane.CLOSED_OPTION); // perform the dialog: final JDialog dlg = optpn.createDialog(panel, "Chart-Daten anzeigen"); dlg.setModal(true);//from w ww .jav a 2s . co m dlg.setResizable(true); dlg.pack(); dlg.setLocationRelativeTo(panel); dlg.setVisible(true); }
From source file:org.broad.igv.track.TrackMenuUtils.java
public static JMenuItem getRemoveMenuItem(final Collection<Track> selectedTracks) { boolean multiple = selectedTracks.size() > 1; JMenuItem item = new JMenuItem("Remove Track" + (multiple ? "s" : "")); item.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { if (selectedTracks.isEmpty()) { return; }/*from w w w . j a va2s.c om*/ StringBuffer buffer = new StringBuffer(); for (Track track : selectedTracks) { buffer.append("\n\t"); buffer.append(track.getName()); } String deleteItems = buffer.toString(); JTextArea textArea = new JTextArea(); textArea.setEditable(false); JScrollPane scrollPane = new JScrollPane(textArea); textArea.setText(deleteItems); JOptionPane optionPane = new JOptionPane(scrollPane, JOptionPane.PLAIN_MESSAGE, JOptionPane.YES_NO_OPTION); optionPane.setPreferredSize(new Dimension(550, 500)); JDialog dialog = optionPane.createDialog(IGV.getMainFrame(), "Remove The Following Tracks"); dialog.setVisible(true); Object choice = optionPane.getValue(); if ((choice == null) || (JOptionPane.YES_OPTION != ((Integer) choice).intValue())) { return; } IGV.getInstance().removeTracks(selectedTracks); IGV.getInstance().doRefresh(); } }); return item; }
From source file:org.executequery.gui.browser.SSHTunnelConnectionPanel.java
public boolean canConnect() { if (useSshCheckbox.isSelected()) { if (!hasValue(userNameField)) { GUIUtilities//w ww. ja v a 2s. com .displayErrorMessage("You have selected SSH Tunnel but have not provided an SSH user name"); return false; } if (!hasValue(portField)) { GUIUtilities.displayErrorMessage("You have selected SSH Tunnel but have not provided an SSH port"); return false; } if (!hasValue(passwordField)) { final JPasswordField field = WidgetFactory.createPasswordField(); JOptionPane optionPane = new JOptionPane(field, JOptionPane.QUESTION_MESSAGE, JOptionPane.OK_CANCEL_OPTION); JDialog dialog = optionPane.createDialog("Enter SSH password"); dialog.addWindowFocusListener(new WindowAdapter() { @Override public void windowGainedFocus(WindowEvent e) { field.requestFocusInWindow(); } }); dialog.pack(); dialog.setLocation(GUIUtilities.getLocationForDialog(dialog.getSize())); dialog.setVisible(true); dialog.dispose(); int result = Integer.parseInt(optionPane.getValue().toString()); if (result == JOptionPane.OK_OPTION) { String password = MiscUtils.charsToString(field.getPassword()); if (StringUtils.isNotBlank(password)) { passwordField.setText(password); return true; } else { GUIUtilities.displayErrorMessage( "You have selected SSH Tunnel but have not provided an SSH password"); // send back here and force them to select cancel if they want to bail return canConnect(); } } return false; } } return true; }
From source file:org.isatools.isacreator.gui.formelements.SubForm.java
private void removalConfirmation(final FieldTypes whatIsBeingRemoved) { // delete reference to protocol in subform // add one to take into account the model and the initial column which contains fields names. final int selectedItem = scrollTable.getSelectedColumn() + 1; // check to ensure the value isn't 0, if it is, nothing is selected in the table since -1 (value returned by model if // no column is selected + 1 = 0!) if ((selectedItem != 0) && (dataEntryForm != null)) { String displayText;/*from w ww .j a v a 2 s . c o m*/ if ((whatIsBeingRemoved == FieldTypes.FACTOR) || (whatIsBeingRemoved == FieldTypes.PROTOCOL)) { displayText = "<html>" + "<b>Confirm deletion of " + fieldType + "</b>" + "<p>Deleting this " + fieldType + " will result in all " + fieldType + "s of this type in subsequent assays</p>" + "<p>being deleted too! Do you wish to continue?</p>" + "</html>"; } else { displayText = "<html>" + "<b>Confirm deletion of " + fieldType + "</b>" + "<p>Deleting this " + fieldType + " will result in its complete removal from this experiment annotation!</p>" + "<p>Do you wish to continue?</p>" + "</html>"; } JOptionPane optionPane = new JOptionPane(displayText, JOptionPane.INFORMATION_MESSAGE, JOptionPane.YES_NO_OPTION); optionPane.addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent event) { if (event.getPropertyName().equals(JOptionPane.VALUE_PROPERTY)) { int lastOptionAnswer = Integer.valueOf(event.getNewValue().toString()); if (lastOptionAnswer == JOptionPane.YES_OPTION) { removeItem(selectedItem); ApplicationManager.getCurrentApplicationInstance().hideSheet(); } else { // just hide the sheet and cancel further actions! ApplicationManager.getCurrentApplicationInstance().hideSheet(); } } } }); optionPane.setIcon(confirmRemoveColumn); UIHelper.applyOptionPaneBackground(optionPane, UIHelper.BG_COLOR); ApplicationManager.getCurrentApplicationInstance() .showJDialogAsSheet(optionPane.createDialog(this, "Confirm Delete")); } else { removeColumn(selectedItem); } }
From source file:org.isatools.isacreator.spreadsheet.Spreadsheet.java
/** * Create the FlatButton panel - a panel which contains graphical representations of the options available * to the user when interacting with the software. *//* w ww . j av a 2 s . c o m*/ private void createButtonPanel() { spreadsheetFunctionPanel = new JPanel(); spreadsheetFunctionPanel.setLayout(new BoxLayout(spreadsheetFunctionPanel, BoxLayout.LINE_AXIS)); spreadsheetFunctionPanel.setBackground(UIHelper.BG_COLOR); addRow = new JLabel(addRowButton); addRow.setToolTipText("<html><b>add row</b>" + "<p>add a new row to the table</p></html>"); addRow.addMouseListener(new MouseAdapter() { public void mousePressed(MouseEvent mouseEvent) { addRow.setIcon(addRowButton); showMultipleRowsGUI(); } public void mouseEntered(MouseEvent mouseEvent) { addRow.setIcon(addRowButtonOver); } public void mouseExited(MouseEvent mouseEvent) { addRow.setIcon(addRowButton); } }); deleteRow = new JLabel(deleteRowButton); deleteRow.setToolTipText("<html><b>remove row</b>" + "<p>remove selected row from table</p></html>"); deleteRow.setEnabled(false); deleteRow.addMouseListener(new MouseAdapter() { public void mousePressed(MouseEvent mouseEvent) { deleteRow.setIcon(deleteRowButton); if (table.getSelectedRow() != -1) { if (!(table.getSelectedRowCount() > 1)) { spreadsheetFunctions.deleteRow(table.getSelectedRow()); } else { spreadsheetFunctions.deleteRow(table.getSelectedRows()); } } } public void mouseEntered(MouseEvent mouseEvent) { deleteRow.setIcon(deleteRowButtonOver); } public void mouseExited(MouseEvent mouseEvent) { deleteRow.setIcon(deleteRowButton); } }); deleteColumn = new JLabel(deleteColumnButton); deleteColumn .setToolTipText("<html><b>remove column</b>" + "<p>remove selected column from table</p></html>"); deleteColumn.setEnabled(false); deleteColumn.addMouseListener(new MouseAdapter() { public void mousePressed(MouseEvent mouseEvent) { deleteColumn.setIcon(deleteColumnButton); if (!(table.getSelectedColumns().length > 1)) { spreadsheetFunctions.deleteColumn(table.getSelectedColumn()); } else { showColumnErrorMessage(); } } public void mouseEntered(MouseEvent mouseEvent) { deleteColumn.setIcon(deleteColumnButtonOver); } public void mouseExited(MouseEvent mouseEvent) { deleteColumn.setIcon(deleteColumnButton); } }); multipleSort = new JLabel(multipleSortButton); multipleSort.setToolTipText( "<html><b>multiple sort</b>" + "<p>perform a multiple sort on the table</p></html>"); multipleSort.addMouseListener(new MouseAdapter() { public void mousePressed(MouseEvent mouseEvent) { multipleSort.setIcon(multipleSortButton); showMultipleColumnSortGUI(); } public void mouseEntered(MouseEvent mouseEvent) { multipleSort.setIcon(multipleSortButtonOver); } public void mouseExited(MouseEvent mouseEvent) { multipleSort.setIcon(multipleSortButton); } }); copyColDown = new JLabel(copyColDownButton); copyColDown.setToolTipText("<html><b>copy column downwards</b>" + "<p>duplicate selected column and copy it from the current</p>" + "<p>position down to the final row in the table</p></html>"); copyColDown.setEnabled(false); copyColDown.addMouseListener(new MouseAdapter() { public void mouseExited(MouseEvent mouseEvent) { copyColDown.setIcon(copyColDownButton); } public void mouseEntered(MouseEvent mouseEvent) { copyColDown.setIcon(copyColDownButtonOver); } public void mousePressed(MouseEvent mouseEvent) { copyColDown.setIcon(copyColDownButton); final int row = table.getSelectedRow(); final int col = table.getSelectedColumn(); if (row != -1 && col != -1) { JOptionPane copyColDownConfirmationPane = new JOptionPane( "<html><b>Confirm Copy of Column...</b><p>Are you sure you wish to copy " + "this column downwards?</p><p>This Action can not be undone!</p></html>", JOptionPane.QUESTION_MESSAGE, JOptionPane.YES_NO_OPTION); copyColDownConfirmationPane.setIcon(copyColumnDownWarningIcon); UIHelper.applyOptionPaneBackground(copyColDownConfirmationPane, UIHelper.BG_COLOR); copyColDownConfirmationPane.addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent event) { if (event.getPropertyName().equals(JOptionPane.VALUE_PROPERTY)) { int lastOptionAnswer = Integer.valueOf(event.getNewValue().toString()); parentFrame.hideSheet(); if (lastOptionAnswer == JOptionPane.YES_OPTION) { spreadsheetFunctions.copyColumnDownwards(row, col); } } } }); parentFrame.showJDialogAsSheet( copyColDownConfirmationPane.createDialog(Spreadsheet.this, "Copy Column?")); } } }); copyRowDown = new JLabel(copyRowDownButton); copyRowDown.setToolTipText( "<html><b>copy row downwards</b>" + "<p>duplicate selected row and copy it from the current</p>" + "<p>position down to the final row</p></html>"); copyRowDown.setEnabled(false); copyRowDown.addMouseListener(new MouseAdapter() { public void mouseExited(MouseEvent mouseEvent) { copyRowDown.setIcon(copyRowDownButton); } public void mouseEntered(MouseEvent mouseEvent) { copyRowDown.setIcon(copyRowDownButtonOver); } public void mousePressed(MouseEvent mouseEvent) { copyRowDown.setIcon(copyRowDownButton); final int row = table.getSelectedRow(); JOptionPane copyRowDownConfirmationPane = new JOptionPane( "<html><b>Confirm Copy of Row...</b><p>Are you sure you wish to copy " + "this row downwards?</p><p>This Action can not be undone!</p>", JOptionPane.QUESTION_MESSAGE, JOptionPane.YES_NO_OPTION); copyRowDownConfirmationPane.setIcon(copyRowDownWarningIcon); UIHelper.applyOptionPaneBackground(copyRowDownConfirmationPane, UIHelper.BG_COLOR); copyRowDownConfirmationPane.addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent event) { if (event.getPropertyName().equals(JOptionPane.VALUE_PROPERTY)) { int lastOptionAnswer = Integer.valueOf(event.getNewValue().toString()); parentFrame.hideSheet(); if (lastOptionAnswer == JOptionPane.YES_OPTION) { spreadsheetFunctions.copyRowDownwards(row); } } } }); parentFrame.showJDialogAsSheet( copyRowDownConfirmationPane.createDialog(Spreadsheet.this, "Copy Row Down?")); } }); addProtocol = new JLabel(addProtocolButton); addProtocol.setToolTipText( "<html><b>add a protocol column</b>" + "<p>Add a protocol column to the table</p></html>"); addProtocol.addMouseListener(new MouseAdapter() { public void mouseEntered(MouseEvent mouseEvent) { addProtocol.setIcon(addProtocolButtonOver); } public void mouseExited(MouseEvent mouseEvent) { addProtocol.setIcon(addProtocolButton); } public void mousePressed(MouseEvent mouseEvent) { addProtocol.setIcon(addProtocolButton); if (addProtocol.isEnabled()) { FieldObject fo = new FieldObject(table.getColumnCount(), "Protocol REF", "Protocol used for experiment", DataTypes.LIST, "", false, false, false); fo.setFieldList(studyDataEntryEnvironment.getProtocolNames()); spreadsheetFunctions.addFieldToReferenceObject(fo); spreadsheetFunctions.addColumnAfterPosition("Protocol REF", null, fo.isRequired(), -1); } } }); addFactor = new JLabel(addFactorButton); addFactor.setToolTipText( "<html><b>add a factor column</b>" + "<p>Add a factor column to the table</p></html>"); addFactor.addMouseListener(new MouseAdapter() { public void mouseEntered(MouseEvent mouseEvent) { addFactor.setIcon(addFactorButtonOver); } public void mouseExited(MouseEvent mouseEvent) { addFactor.setIcon(addFactorButton); } public void mousePressed(MouseEvent mouseEvent) { addFactor.setIcon(addFactorButton); if (addFactor.isEnabled()) { showAddColumnsGUI(AddColumnGUI.ADD_FACTOR_COLUMN); } } }); addCharacteristic = new JLabel(addCharacteristicButton); addCharacteristic.setToolTipText("<html><b>add a characteristic column</b>" + "<p>Add a characteristic column to the table</p></html>"); addCharacteristic.addMouseListener(new MouseAdapter() { public void mouseEntered(MouseEvent mouseEvent) { addCharacteristic.setIcon(addCharacteristicButtonOver); } public void mouseExited(MouseEvent mouseEvent) { addCharacteristic.setIcon(addCharacteristicButton); } public void mousePressed(MouseEvent mouseEvent) { addCharacteristic.setIcon(addCharacteristicButton); if (addCharacteristic.isEnabled()) { showAddColumnsGUI(AddColumnGUI.ADD_CHARACTERISTIC_COLUMN); } } }); addParameter = new JLabel(addParameterButton); addParameter.setToolTipText( "<html><b>add a parameter column</b>" + "<p>Add a parameter column to the table</p></html>"); addParameter.addMouseListener(new MouseAdapter() { public void mouseEntered(MouseEvent mouseEvent) { addParameter.setIcon(addParameterButtonOver); } public void mouseExited(MouseEvent mouseEvent) { addParameter.setIcon(addParameterButton); } public void mousePressed(MouseEvent mouseEvent) { addParameter.setIcon(addParameterButton); if (addParameter.isEnabled()) { showAddColumnsGUI(AddColumnGUI.ADD_PARAMETER_COLUMN); } } }); undo = new JLabel(undoButton); undo.setToolTipText("<html><b>undo previous action<b></html>"); undo.setEnabled(undoManager.canUndo()); undo.addMouseListener(new MouseAdapter() { public void mousePressed(MouseEvent mouseEvent) { undo.setIcon(undoButton); undoManager.undo(); if (highlightActive) { setRowsToDefaultColor(); } table.addNotify(); } public void mouseEntered(MouseEvent mouseEvent) { undo.setIcon(undoButtonOver); } public void mouseExited(MouseEvent mouseEvent) { undo.setIcon(undoButton); } }); redo = new JLabel(redoButton); redo.setToolTipText("<html><b>redo action<b></html>"); redo.setEnabled(undoManager.canRedo()); redo.addMouseListener(new MouseAdapter() { public void mousePressed(MouseEvent mouseEvent) { redo.setIcon(redoButton); undoManager.redo(); if (highlightActive) { setRowsToDefaultColor(); } table.addNotify(); } public void mouseEntered(MouseEvent mouseEvent) { redo.setIcon(redoButtonOver); } public void mouseExited(MouseEvent mouseEvent) { redo.setIcon(redoButton); } }); transpose = new JLabel(transposeIcon); transpose.setToolTipText("<html>View a transposed version of this spreadsheet</html>"); transpose.addMouseListener(new MouseAdapter() { public void mouseExited(MouseEvent mouseEvent) { transpose.setIcon(transposeIcon); } public void mouseEntered(MouseEvent mouseEvent) { transpose.setIcon(transposeIconOver); } public void mousePressed(MouseEvent mouseEvent) { showTransposeSpreadsheetGUI(); } }); addButtons(); if (studyDataEntryEnvironment != null) { JPanel labelContainer = new JPanel(new GridLayout(1, 1)); labelContainer.setBackground(UIHelper.BG_COLOR); JLabel lab = UIHelper.createLabel(spreadsheetTitle, UIHelper.VER_10_PLAIN, UIHelper.DARK_GREEN_COLOR, JLabel.RIGHT); lab.setBackground(UIHelper.BG_COLOR); lab.setVerticalAlignment(JLabel.CENTER); lab.setPreferredSize(new Dimension(200, 30)); labelContainer.add(lab); spreadsheetFunctionPanel.add(labelContainer); spreadsheetFunctionPanel.add(Box.createHorizontalStrut(10)); } add(spreadsheetFunctionPanel, BorderLayout.NORTH); }
From source file:org.zeromeaner.gui.reskin.StandaloneFrame.java
private void createCards() { introPanel = new StandaloneLicensePanel(); content.add(introPanel, CARD_INTRO); playCard = new JPanel(new BorderLayout()); content.add(playCard, CARD_PLAY);/* ww w . j a v a 2s . c o m*/ JPanel confirm = new JPanel(new GridBagLayout()); JOptionPane option = new JOptionPane("A game is in open. End this game?", JOptionPane.QUESTION_MESSAGE, JOptionPane.YES_NO_OPTION); option.addPropertyChangeListener(JOptionPane.VALUE_PROPERTY, new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { if (!CARD_PLAY_END.equals(currentCard)) return; if (evt.getNewValue().equals(JOptionPane.YES_OPTION)) { gamePanel.shutdown(); try { gamePanel.shutdownWait(); } catch (InterruptedException ie) { } contentCards.show(content, nextCard); currentCard = nextCard; } if (evt.getNewValue().equals(JOptionPane.NO_OPTION)) { contentCards.show(content, CARD_PLAY); currentCard = CARD_PLAY; playButton.setSelected(true); } ((JOptionPane) evt.getSource()).setValue(-1); } }); GridBagConstraints cx = new GridBagConstraints(0, 0, 1, 1, 1, 1, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(10, 10, 10, 10), 0, 0); confirm.add(option, cx); content.add(confirm, CARD_PLAY_END); content.add(new StandaloneModeselectPanel(), CARD_MODESELECT); netplayCard = new JPanel(new BorderLayout()); netplayCard.add(netLobby, BorderLayout.SOUTH); content.add(netplayCard, CARD_NETPLAY); confirm = new JPanel(new GridBagLayout()); option = new JOptionPane("A netplay game is open. End this game and disconnect?", JOptionPane.QUESTION_MESSAGE, JOptionPane.YES_NO_OPTION); option.addPropertyChangeListener(JOptionPane.VALUE_PROPERTY, new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { if (!CARD_NETPLAY_END.equals(currentCard)) return; if (evt.getNewValue().equals(JOptionPane.YES_OPTION)) { gamePanel.shutdown(); try { gamePanel.shutdownWait(); } catch (InterruptedException ie) { } netLobby.disconnect(); contentCards.show(content, nextCard); currentCard = nextCard; } if (evt.getNewValue().equals(JOptionPane.NO_OPTION)) { contentCards.show(content, CARD_NETPLAY); currentCard = CARD_NETPLAY; netplayButton.setSelected(true); } ((JOptionPane) evt.getSource()).setValue(-1); } }); cx = new GridBagConstraints(0, 0, 1, 1, 1, 1, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(10, 10, 10, 10), 0, 0); confirm.add(option, cx); content.add(confirm, CARD_NETPLAY_END); StandaloneKeyConfig kc = new StandaloneKeyConfig(this); kc.load(0); content.add(kc, CARD_KEYS_1P); kc = new StandaloneKeyConfig(this); kc.load(1); content.add(kc, CARD_KEYS_2P); StandaloneGameTuningPanel gt = new StandaloneGameTuningPanel(); gt.load(0); content.add(gt, CARD_TUNING_1P); gt = new StandaloneGameTuningPanel(); gt.load(1); content.add(gt, CARD_TUNING_2P); StandaloneAISelectPanel ai = new StandaloneAISelectPanel(); ai.load(0); content.add(ai, CARD_AI_1P); ai = new StandaloneAISelectPanel(); ai.load(1); content.add(ai, CARD_AI_2P); StandaloneGeneralConfigPanel gc = new StandaloneGeneralConfigPanel(); gc.load(); content.add(gc, CARD_GENERAL); final JFileChooser fc = FileSystemViews.get().fileChooser("replay/"); fc.setFileFilter(new FileFilter() { @Override public String getDescription() { return "Zeromeaner Replay Files"; } @Override public boolean accept(File f) { return f.isDirectory() || f.getName().endsWith(".zrep"); } }); fc.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (!e.getActionCommand().equals(JFileChooser.APPROVE_SELECTION)) return; JFileChooser fc = (JFileChooser) e.getSource(); String path = fc.getSelectedFile().getPath(); if (!path.contains("replay/")) path = "replay/" + path; startReplayGame(path); } }); fc.addComponentListener(new ComponentAdapter() { @Override public void componentShown(ComponentEvent e) { fc.rescanCurrentDirectory(); } }); content.add(fc, CARD_OPEN); content.add(new StandaloneFeedbackPanel(), CARD_FEEDBACK); }
From source file:pl.edu.pw.appt.GUI.java
private void jMenuItem4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem4ActionPerformed boolean zal = false; JTextField z1 = new JTextField(); JTextField z2 = new JTextField(); Object[] message = { "Zdarzenie 1", z1, "Zdarzenie 2", z2 }; JOptionPane pane = new JOptionPane(message, JOptionPane.PLAIN_MESSAGE, JOptionPane.OK_CANCEL_OPTION); pane.createDialog(null, "Badanie zdarze").setVisible(true); if (selectSystem.getSelectedIndex() != -1) { zal = server.messages.isDependent1(Integer.parseInt(z1.getText()), Integer.parseInt(z2.getText()), selectSystem.getSelectedItem().toString()); JOptionPane.showMessageDialog(null, zal ? "Zdarzenia s zalene" : "Zdarzenia s niezalene", "Badanie zdarze", JOptionPane.WARNING_MESSAGE); }/*from www . j av a 2s .c o m*/ }
From source file:pt.lsts.neptus.util.logdownload.LogsDownloaderWorkerActions.java
@SuppressWarnings("serial") private AbstractAction createDeleteSelectedLogFoldersAction() { return new AbstractAction() { @Override//from w w w. j a v a2s. c o m public void actionPerformed(ActionEvent e) { if (!gui.validateAndSetUI()) { gui.popupErrorConfigurationDialog(); return; } AsyncTask task = new AsyncTask() { @Override public Object run() throws Exception { gui.deleteSelectedLogFoldersButton.setEnabled(false); // logFolderList.setEnabled(false); // logFilesList.setEnabled(false); Object[] objArray = gui.logFolderList.getSelectedValues(); if (objArray.length == 0) return null; JOptionPane jop = new JOptionPane( I18n.text("Are you sure you want to delete " + "selected log folders from remote system?"), JOptionPane.QUESTION_MESSAGE, JOptionPane.YES_NO_OPTION); JDialog dialog = jop.createDialog(gui.frameCompHolder, I18n.text("Remote Delete Confirmation")); dialog.setModalityType(ModalityType.DOCUMENT_MODAL); dialog.setVisible(true); Object userChoice = jop.getValue(); try { if (((Integer) userChoice) != JOptionPane.YES_OPTION) { return null; } } catch (Exception e2) { NeptusLog.pub().error(e2.getMessage()); return null; } gui.deleteSelectedLogFoldersButton.setEnabled(true); for (Object comp : objArray) { try { LogFolderInfo logFd = (LogFolderInfo) comp; boolean resDel = worker.deleteLogFolderFromServer(logFd); if (resDel) { logFd.setState(LogFolderInfo.State.LOCAL); LinkedHashSet<LogFileInfo> logFiles = logFd.getLogFiles(); LinkedHashSet<LogFileInfo> toDelFL = LogsDownloaderWorkerGUIUtil .updateLogFilesStateDeleted(logFiles, gui.downloadWorkersHolder, worker.getDirBaseToStoreFiles(), worker.getLogLabel()); for (LogFileInfo lfx : toDelFL) { if (resetting) break; logFd.getLogFiles().remove(lfx); } } } catch (Exception e) { NeptusLog.pub().debug(e.getMessage()); } if (resetting) break; } worker.updateFilesListGUIForFolderSelected(); return true; } @Override public void finish() { gui.deleteSelectedLogFoldersButton.setEnabled(true); gui.logFilesList.revalidate(); gui.logFilesList.repaint(); gui.logFilesList.setEnabled(true); gui.logFolderList.revalidate(); gui.logFolderList.repaint(); gui.logFolderList.setEnabled(true); try { this.getResultOrThrow(); } catch (Exception e) { e.printStackTrace(); } } }; AsyncWorker.getWorkerThread().postTask(task); } }; }