@Override public boolean stopCellEditing() { try { editor.commitEdit(); spinner.commitEdit(); resetRow(); } catch (java.text.ParseException e) { JOptionPane.showMessageDialog(null, "Invalid value, discarding."); } return super.stopCellEditing(); } }
try { editor.commitEdit(); spinner.commitEdit(); } catch ( java.text.ParseException e ) { JOptionPane.showMessageDialog(null,
public float getStrokeWidth() { try { this.strokeSpinner.commitEdit(); } catch (ParseException e) { log.log(Level.WARNING, "Your edits in the grid line thickness spinner could not be parsed as Float."); } return (Float) this.strokeSpinner.getValue(); }
public Dimension getGridSize() { try { this.widthSpinner.commitEdit(); this.heightSpinner.commitEdit(); } catch (ParseException e) { log.log(Level.WARNING, "\"One of your edits in the grid size spinners could not be parsed as Integer."); } return new Dimension((Integer) this.widthSpinner.getValue(), (Integer) this.heightSpinner.getValue()); } }
/** This is needed to read data manually typed in spinners fields. */ private void commitSpinners () { try { switch (readKind()) { case GLOBAL: globalData.spinner.commitEdit(); break; case ADAPTIVE: localDataMean.spinner.commitEdit(); localDataDev.spinner.commitEdit(); break; default: } } catch (ParseException ignored) { } }
@Override public void dialogValidated() { // Commits the current spinner value in case it was being edited and 'enter' was pressed // (the spinner value would otherwise not be committed) try { portSpinner.commitEdit(); } catch(ParseException e) { } updateValues(); } }
@Override public void dialogValidated() { // Commits the current spinner value in case it was being edited and 'enter' was pressed // (the spinner value would otherwise not be committed) try { portSpinner.commitEdit(); } catch(ParseException e) { } updateValues(); }
@Override public void dialogValidated() { // Commits the current spinner value in case it was being edited and 'enter' was pressed // (the spinner value would otherwise not be committed) try { portSpinner.commitEdit(); } catch(ParseException e) { } updateValues(); } }
@Override public void dialogValidated() { // Commits the current spinner value in case it was being edited and 'enter' was pressed // (the spinner value would otherwise not be committed) try { portSpinner.commitEdit(); } catch(ParseException e) { } updateValues(); } }
@Override public void dialogValidated() { // Commits the current spinner value in case it was being edited and 'enter' was pressed // (the spinner value would otherwise not be committed) try { portSpinner.commitEdit(); } catch(ParseException e) { } updateValues(); } }
/** * Commits the currently edited values. If commit fails, focus will be set on the offending * field. * * @throws ParseException If at least one of currently edited value couldn't be commited. */ public void commitEdit() throws ParseException { JSpinner focus=null; try { (focus=tmin).commitEdit(); (focus=tmax).commitEdit(); (focus=xmin).commitEdit(); (focus=xmax).commitEdit(); (focus=ymin).commitEdit(); (focus=ymax).commitEdit(); (focus=xres).commitEdit(); (focus=yres).commitEdit(); checkAngle(focus=xmin, false); checkAngle(focus=xmax, false); checkAngle(focus=ymin, true); checkAngle(focus=ymax, true); } catch (ParseException exception) { focus.requestFocus(); throw exception; } }
@Override public void commitEdit() throws ParseException { try { super.commitEdit(); } catch (ParseException ex) { if ("".equals(getText())) { model.setValue(null); } } }
@Override public boolean stopCellEditing() { System.err.println("Stopping edit"); try { editor.commitEdit(); spinner.commitEdit(); } catch (java.text.ParseException e) { JOptionPane.showMessageDialog(null, "Invalid value, discarding."); } return super.stopCellEditing(); } }
@Override public boolean stopCellEditing() { try { editor.commitEdit(); spinner.commitEdit(); } catch (java.text.ParseException e) { JOptionPane.showMessageDialog(null, "Invalid value, discarding."); } return super.stopCellEditing(); } }
@RunsInEDT private static void commit(final @Nonnull JSpinner spinner) { execute(() -> spinner.commitEdit()); }
@Override public boolean stopCellEditing() { try { editor.commitEdit(); spinner.commitEdit(); } catch (java.text.ParseException e) { JOptionPane.showMessageDialog(null, "Invalid value, discarding."); } return super.stopCellEditing(); } }
@Override public void valueChanged(ListSelectionEvent e) { // make sure the user is done adjusting if (!e.getValueIsAdjusting()) { JList list = (JList) e.getSource(); int[] selections = list.getSelectedIndices(); short value = 0; for (int i = 0; i < selections.length; i++) { value |= CATEGORIES[selections[i]].value; } spinnerMaskBits.setValue(value); try { spinnerMaskBits.commitEdit(); } catch (Exception ex) { } } } });
@Override public void valueChanged(ListSelectionEvent e) { // make sure the user is done adjusting if (!e.getValueIsAdjusting()) { JList list = (JList) e.getSource(); int[] selections = list.getSelectedIndices(); short value = 0; for (int i = 0; i < selections.length; i++) { value |= CATEGORIES[selections[i]].value; } spinnerCategoryBits.setValue(value); try { spinnerCategoryBits.commitEdit(); } catch (Exception ex) { } } } });
/** * Read an integer value from a spinner. * * @param name * Name of the spinner. * @param displayName * Name used in the message if there is an error. * @param formPanel * The form panel containing the component. * @return The integer value selected. */ public static int getSpinner(String name, String displayName, FormPanel formPanel) { int width = 0; JSpinner spinner = formPanel.getSpinner(name); try { spinner.commitEdit(); width = ((Integer) spinner.getValue()).intValue(); } catch (ParseException e) { JOptionPane.showMessageDialog(spinner, "There is an invalid " + displayName + " specified: " + ((JTextField) spinner.getEditor()).getText(), "Error!", JOptionPane.ERROR_MESSAGE); throw new IllegalStateException(e); } // endtry return width; }
/** * Updates the time zone in text fields. This method is automatically invoked * by {@link JComboBox} on user's selection. It is also (indirectly) invoked * on {@link #setTimeZone} call. */ private void update(final TimeZone timezone) { boolean refresh=true; try { tmin.commitEdit(); tmax.commitEdit(); } catch (ParseException exception) { refresh = false; } ((JSpinner.DateEditor)tmin.getEditor()).getFormat().setTimeZone(timezone); ((JSpinner.DateEditor)tmax.getEditor()).getFormat().setTimeZone(timezone); if (refresh) { // TODO: If a "JSpinner.reformat()" method was available, we would use it here. fireStateChanged((AbstractSpinnerModel)tmin.getModel()); fireStateChanged((AbstractSpinnerModel)tmax.getModel()); } }