java.text.Format.Field Java Examples
The following examples show how to use
java.text.Format.Field.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AquaSpinnerUI.java From dragonwell8_jdk with GNU General Public License v2.0 | 6 votes |
/** * Selects the passed in field, returning true if it is found, * false otherwise. */ private boolean select(final JFormattedTextField ftf, final AttributedCharacterIterator iterator, final DateFormat.Field field) { final int max = ftf.getDocument().getLength(); iterator.first(); do { final Map<Attribute,Object> attrs = iterator.getAttributes(); if (attrs == null || !attrs.containsKey(field)) continue; final int start = iterator.getRunStart(field); final int end = iterator.getRunLimit(field); if (start != -1 && end != -1 && start <= max && end <= max) { ftf.select(start, end); } return true; } while (iterator.next() != CharacterIterator.DONE); return false; }
Example #2
Source File: AquaSpinnerUI.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 6 votes |
/** * Selects the passed in field, returning true if it is found, * false otherwise. */ private boolean select(final JFormattedTextField ftf, final AttributedCharacterIterator iterator, final DateFormat.Field field) { final int max = ftf.getDocument().getLength(); iterator.first(); do { final Map<Attribute,Object> attrs = iterator.getAttributes(); if (attrs == null || !attrs.containsKey(field)) continue; final int start = iterator.getRunStart(field); final int end = iterator.getRunLimit(field); if (start != -1 && end != -1 && start <= max && end <= max) { ftf.select(start, end); } return true; } while (iterator.next() != CharacterIterator.DONE); return false; }
Example #3
Source File: AquaSpinnerUI.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 6 votes |
/** * If the spinner's editor is a DateEditor, this selects the field * associated with the value that is being incremented. */ private void select(final JSpinner spinnerComponent) { final JComponent editor = spinnerComponent.getEditor(); if (!(editor instanceof JSpinner.DateEditor)) return; final JSpinner.DateEditor dateEditor = (JSpinner.DateEditor)editor; final JFormattedTextField ftf = dateEditor.getTextField(); final Format format = dateEditor.getFormat(); Object value; if (format == null || (value = spinnerComponent.getValue()) == null) return; final SpinnerDateModel model = dateEditor.getModel(); final DateFormat.Field field = DateFormat.Field.ofCalendarField(model.getCalendarField()); if (field == null) return; try { final AttributedCharacterIterator iterator = format.formatToCharacterIterator(value); if (!select(ftf, iterator, field) && field == DateFormat.Field.HOUR0) { select(ftf, iterator, DateFormat.Field.HOUR1); } } catch (final IllegalArgumentException iae) {} }
Example #4
Source File: AquaSpinnerUI.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
/** * Selects the passed in field, returning true if it is found, * false otherwise. */ private boolean select(final JFormattedTextField ftf, final AttributedCharacterIterator iterator, final DateFormat.Field field) { final int max = ftf.getDocument().getLength(); iterator.first(); do { final Map<Attribute,Object> attrs = iterator.getAttributes(); if (attrs == null || !attrs.containsKey(field)) continue; final int start = iterator.getRunStart(field); final int end = iterator.getRunLimit(field); if (start != -1 && end != -1 && start <= max && end <= max) { ftf.select(start, end); } return true; } while (iterator.next() != CharacterIterator.DONE); return false; }
Example #5
Source File: AquaSpinnerUI.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
/** * If the spinner's editor is a DateEditor, this selects the field * associated with the value that is being incremented. */ private void select(final JSpinner spinnerComponent) { final JComponent editor = spinnerComponent.getEditor(); if (!(editor instanceof JSpinner.DateEditor)) return; final JSpinner.DateEditor dateEditor = (JSpinner.DateEditor)editor; final JFormattedTextField ftf = dateEditor.getTextField(); final Format format = dateEditor.getFormat(); Object value; if (format == null || (value = spinnerComponent.getValue()) == null) return; final SpinnerDateModel model = dateEditor.getModel(); final DateFormat.Field field = DateFormat.Field.ofCalendarField(model.getCalendarField()); if (field == null) return; try { final AttributedCharacterIterator iterator = format.formatToCharacterIterator(value); if (!select(ftf, iterator, field) && field == DateFormat.Field.HOUR0) { select(ftf, iterator, DateFormat.Field.HOUR1); } } catch (final IllegalArgumentException iae) {} }
Example #6
Source File: AquaSpinnerUI.java From jdk8u_jdk with GNU General Public License v2.0 | 6 votes |
/** * Selects the passed in field, returning true if it is found, * false otherwise. */ private boolean select(final JFormattedTextField ftf, final AttributedCharacterIterator iterator, final DateFormat.Field field) { final int max = ftf.getDocument().getLength(); iterator.first(); do { final Map<Attribute,Object> attrs = iterator.getAttributes(); if (attrs == null || !attrs.containsKey(field)) continue; final int start = iterator.getRunStart(field); final int end = iterator.getRunLimit(field); if (start != -1 && end != -1 && start <= max && end <= max) { ftf.select(start, end); } return true; } while (iterator.next() != CharacterIterator.DONE); return false; }
Example #7
Source File: AquaSpinnerUI.java From jdk8u_jdk with GNU General Public License v2.0 | 6 votes |
/** * If the spinner's editor is a DateEditor, this selects the field * associated with the value that is being incremented. */ private void select(final JSpinner spinnerComponent) { final JComponent editor = spinnerComponent.getEditor(); if (!(editor instanceof JSpinner.DateEditor)) return; final JSpinner.DateEditor dateEditor = (JSpinner.DateEditor)editor; final JFormattedTextField ftf = dateEditor.getTextField(); final Format format = dateEditor.getFormat(); Object value; if (format == null || (value = spinnerComponent.getValue()) == null) return; final SpinnerDateModel model = dateEditor.getModel(); final DateFormat.Field field = DateFormat.Field.ofCalendarField(model.getCalendarField()); if (field == null) return; try { final AttributedCharacterIterator iterator = format.formatToCharacterIterator(value); if (!select(ftf, iterator, field) && field == DateFormat.Field.HOUR0) { select(ftf, iterator, DateFormat.Field.HOUR1); } } catch (final IllegalArgumentException iae) {} }
Example #8
Source File: AquaSpinnerUI.java From openjdk-8 with GNU General Public License v2.0 | 6 votes |
/** * Selects the passed in field, returning true if it is found, * false otherwise. */ private boolean select(final JFormattedTextField ftf, final AttributedCharacterIterator iterator, final DateFormat.Field field) { final int max = ftf.getDocument().getLength(); iterator.first(); do { final Map<Attribute,Object> attrs = iterator.getAttributes(); if (attrs == null || !attrs.containsKey(field)) continue; final int start = iterator.getRunStart(field); final int end = iterator.getRunLimit(field); if (start != -1 && end != -1 && start <= max && end <= max) { ftf.select(start, end); } return true; } while (iterator.next() != CharacterIterator.DONE); return false; }
Example #9
Source File: AquaSpinnerUI.java From openjdk-8 with GNU General Public License v2.0 | 6 votes |
/** * If the spinner's editor is a DateEditor, this selects the field * associated with the value that is being incremented. */ private void select(final JSpinner spinnerComponent) { final JComponent editor = spinnerComponent.getEditor(); if (!(editor instanceof JSpinner.DateEditor)) return; final JSpinner.DateEditor dateEditor = (JSpinner.DateEditor)editor; final JFormattedTextField ftf = dateEditor.getTextField(); final Format format = dateEditor.getFormat(); Object value; if (format == null || (value = spinnerComponent.getValue()) == null) return; final SpinnerDateModel model = dateEditor.getModel(); final DateFormat.Field field = DateFormat.Field.ofCalendarField(model.getCalendarField()); if (field == null) return; try { final AttributedCharacterIterator iterator = format.formatToCharacterIterator(value); if (!select(ftf, iterator, field) && field == DateFormat.Field.HOUR0) { select(ftf, iterator, DateFormat.Field.HOUR1); } } catch (final IllegalArgumentException iae) {} }
Example #10
Source File: AquaSpinnerUI.java From openjdk-8-source with GNU General Public License v2.0 | 6 votes |
/** * Selects the passed in field, returning true if it is found, * false otherwise. */ private boolean select(final JFormattedTextField ftf, final AttributedCharacterIterator iterator, final DateFormat.Field field) { final int max = ftf.getDocument().getLength(); iterator.first(); do { final Map<Attribute,Object> attrs = iterator.getAttributes(); if (attrs == null || !attrs.containsKey(field)) continue; final int start = iterator.getRunStart(field); final int end = iterator.getRunLimit(field); if (start != -1 && end != -1 && start <= max && end <= max) { ftf.select(start, end); } return true; } while (iterator.next() != CharacterIterator.DONE); return false; }
Example #11
Source File: AquaSpinnerUI.java From openjdk-8-source with GNU General Public License v2.0 | 6 votes |
/** * If the spinner's editor is a DateEditor, this selects the field * associated with the value that is being incremented. */ private void select(final JSpinner spinnerComponent) { final JComponent editor = spinnerComponent.getEditor(); if (!(editor instanceof JSpinner.DateEditor)) return; final JSpinner.DateEditor dateEditor = (JSpinner.DateEditor)editor; final JFormattedTextField ftf = dateEditor.getTextField(); final Format format = dateEditor.getFormat(); Object value; if (format == null || (value = spinnerComponent.getValue()) == null) return; final SpinnerDateModel model = dateEditor.getModel(); final DateFormat.Field field = DateFormat.Field.ofCalendarField(model.getCalendarField()); if (field == null) return; try { final AttributedCharacterIterator iterator = format.formatToCharacterIterator(value); if (!select(ftf, iterator, field) && field == DateFormat.Field.HOUR0) { select(ftf, iterator, DateFormat.Field.HOUR1); } } catch (final IllegalArgumentException iae) {} }
Example #12
Source File: AquaSpinnerUI.java From hottub with GNU General Public License v2.0 | 6 votes |
/** * Selects the passed in field, returning true if it is found, * false otherwise. */ private boolean select(final JFormattedTextField ftf, final AttributedCharacterIterator iterator, final DateFormat.Field field) { final int max = ftf.getDocument().getLength(); iterator.first(); do { final Map<Attribute,Object> attrs = iterator.getAttributes(); if (attrs == null || !attrs.containsKey(field)) continue; final int start = iterator.getRunStart(field); final int end = iterator.getRunLimit(field); if (start != -1 && end != -1 && start <= max && end <= max) { ftf.select(start, end); } return true; } while (iterator.next() != CharacterIterator.DONE); return false; }
Example #13
Source File: AquaSpinnerUI.java From hottub with GNU General Public License v2.0 | 6 votes |
/** * If the spinner's editor is a DateEditor, this selects the field * associated with the value that is being incremented. */ private void select(final JSpinner spinnerComponent) { final JComponent editor = spinnerComponent.getEditor(); if (!(editor instanceof JSpinner.DateEditor)) return; final JSpinner.DateEditor dateEditor = (JSpinner.DateEditor)editor; final JFormattedTextField ftf = dateEditor.getTextField(); final Format format = dateEditor.getFormat(); Object value; if (format == null || (value = spinnerComponent.getValue()) == null) return; final SpinnerDateModel model = dateEditor.getModel(); final DateFormat.Field field = DateFormat.Field.ofCalendarField(model.getCalendarField()); if (field == null) return; try { final AttributedCharacterIterator iterator = format.formatToCharacterIterator(value); if (!select(ftf, iterator, field) && field == DateFormat.Field.HOUR0) { select(ftf, iterator, DateFormat.Field.HOUR1); } } catch (final IllegalArgumentException iae) {} }
Example #14
Source File: AquaSpinnerUI.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
/** * Selects the passed in field, returning true if it is found, * false otherwise. */ private boolean select(final JFormattedTextField ftf, final AttributedCharacterIterator iterator, final DateFormat.Field field) { final int max = ftf.getDocument().getLength(); iterator.first(); do { final Map<Attribute,Object> attrs = iterator.getAttributes(); if (attrs == null || !attrs.containsKey(field)) continue; final int start = iterator.getRunStart(field); final int end = iterator.getRunLimit(field); if (start != -1 && end != -1 && start <= max && end <= max) { ftf.select(start, end); } return true; } while (iterator.next() != CharacterIterator.DONE); return false; }
Example #15
Source File: AquaSpinnerUI.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
/** * If the spinner's editor is a DateEditor, this selects the field * associated with the value that is being incremented. */ private void select(final JSpinner spinnerComponent) { final JComponent editor = spinnerComponent.getEditor(); if (!(editor instanceof JSpinner.DateEditor)) return; final JSpinner.DateEditor dateEditor = (JSpinner.DateEditor)editor; final JFormattedTextField ftf = dateEditor.getTextField(); final Format format = dateEditor.getFormat(); Object value; if (format == null || (value = spinnerComponent.getValue()) == null) return; final SpinnerDateModel model = dateEditor.getModel(); final DateFormat.Field field = DateFormat.Field.ofCalendarField(model.getCalendarField()); if (field == null) return; try { final AttributedCharacterIterator iterator = format.formatToCharacterIterator(value); if (!select(ftf, iterator, field) && field == DateFormat.Field.HOUR0) { select(ftf, iterator, DateFormat.Field.HOUR1); } } catch (final IllegalArgumentException iae) {} }
Example #16
Source File: AquaSpinnerUI.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
/** * Selects the passed in field, returning true if it is found, false * otherwise. */ private boolean select(final JFormattedTextField ftf, final AttributedCharacterIterator iterator, final DateFormat.Field field) { final int max = ftf.getDocument().getLength(); iterator.first(); do { final Map<Attribute, Object> attrs = iterator.getAttributes(); if (attrs == null || !attrs.containsKey(field)) { continue; } final int start = iterator.getRunStart(field); final int end = iterator.getRunLimit(field); if (start != -1 && end != -1 && start <= max && end <= max) { ftf.select(start, end); } return true; } while (iterator.next() != CharacterIterator.DONE); return false; }
Example #17
Source File: AquaSpinnerUI.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
/** * Selects the passed in field, returning true if it is found, * false otherwise. */ private boolean select(final JFormattedTextField ftf, final AttributedCharacterIterator iterator, final DateFormat.Field field) { final int max = ftf.getDocument().getLength(); iterator.first(); do { final Map<Attribute,Object> attrs = iterator.getAttributes(); if (attrs == null || !attrs.containsKey(field)) continue; final int start = iterator.getRunStart(field); final int end = iterator.getRunLimit(field); if (start != -1 && end != -1 && start <= max && end <= max) { ftf.select(start, end); } return true; } while (iterator.next() != CharacterIterator.DONE); return false; }
Example #18
Source File: AquaSpinnerUI.java From dragonwell8_jdk with GNU General Public License v2.0 | 6 votes |
/** * If the spinner's editor is a DateEditor, this selects the field * associated with the value that is being incremented. */ private void select(final JSpinner spinnerComponent) { final JComponent editor = spinnerComponent.getEditor(); if (!(editor instanceof JSpinner.DateEditor)) return; final JSpinner.DateEditor dateEditor = (JSpinner.DateEditor)editor; final JFormattedTextField ftf = dateEditor.getTextField(); final Format format = dateEditor.getFormat(); Object value; if (format == null || (value = spinnerComponent.getValue()) == null) return; final SpinnerDateModel model = dateEditor.getModel(); final DateFormat.Field field = DateFormat.Field.ofCalendarField(model.getCalendarField()); if (field == null) return; try { final AttributedCharacterIterator iterator = format.formatToCharacterIterator(value); if (!select(ftf, iterator, field) && field == DateFormat.Field.HOUR0) { select(ftf, iterator, DateFormat.Field.HOUR1); } } catch (final IllegalArgumentException iae) {} }
Example #19
Source File: AquaSpinnerUI.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
/** * If the spinner's editor is a DateEditor, this selects the field * associated with the value that is being incremented. */ private void select(final JSpinner spinnerComponent) { final JComponent editor = spinnerComponent.getEditor(); if (!(editor instanceof JSpinner.DateEditor)) return; final JSpinner.DateEditor dateEditor = (JSpinner.DateEditor)editor; final JFormattedTextField ftf = dateEditor.getTextField(); final Format format = dateEditor.getFormat(); Object value; if (format == null || (value = spinnerComponent.getValue()) == null) return; final SpinnerDateModel model = dateEditor.getModel(); final DateFormat.Field field = DateFormat.Field.ofCalendarField(model.getCalendarField()); if (field == null) return; try { final AttributedCharacterIterator iterator = format.formatToCharacterIterator(value); if (!select(ftf, iterator, field) && field == DateFormat.Field.HOUR0) { select(ftf, iterator, DateFormat.Field.HOUR1); } } catch (final IllegalArgumentException iae) {} }
Example #20
Source File: AquaSpinnerUI.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
/** * If the spinner's editor is a DateEditor, this selects the field * associated with the value that is being incremented. */ private void select(final JSpinner spinnerComponent) { final JComponent editor = spinnerComponent.getEditor(); if (!(editor instanceof JSpinner.DateEditor)) return; final JSpinner.DateEditor dateEditor = (JSpinner.DateEditor)editor; final JFormattedTextField ftf = dateEditor.getTextField(); final Format format = dateEditor.getFormat(); Object value; if (format == null || (value = spinnerComponent.getValue()) == null) return; final SpinnerDateModel model = dateEditor.getModel(); final DateFormat.Field field = DateFormat.Field.ofCalendarField(model.getCalendarField()); if (field == null) return; try { final AttributedCharacterIterator iterator = format.formatToCharacterIterator(value); if (!select(ftf, iterator, field) && field == DateFormat.Field.HOUR0) { select(ftf, iterator, DateFormat.Field.HOUR1); } } catch (final IllegalArgumentException iae) {} }
Example #21
Source File: AquaSpinnerUI.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
/** * Selects the passed in field, returning true if it is found, * false otherwise. */ private boolean select(final JFormattedTextField ftf, final AttributedCharacterIterator iterator, final DateFormat.Field field) { final int max = ftf.getDocument().getLength(); iterator.first(); do { final Map<Attribute,Object> attrs = iterator.getAttributes(); if (attrs == null || !attrs.containsKey(field)) continue; final int start = iterator.getRunStart(field); final int end = iterator.getRunLimit(field); if (start != -1 && end != -1 && start <= max && end <= max) { ftf.select(start, end); } return true; } while (iterator.next() != CharacterIterator.DONE); return false; }
Example #22
Source File: AquaSpinnerUI.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
/** * Selects the passed in field, returning true if it is found, * false otherwise. */ private boolean select(final JFormattedTextField ftf, final AttributedCharacterIterator iterator, final DateFormat.Field field) { final int max = ftf.getDocument().getLength(); iterator.first(); do { final Map<Attribute,Object> attrs = iterator.getAttributes(); if (attrs == null || !attrs.containsKey(field)) continue; final int start = iterator.getRunStart(field); final int end = iterator.getRunLimit(field); if (start != -1 && end != -1 && start <= max && end <= max) { ftf.select(start, end); } return true; } while (iterator.next() != CharacterIterator.DONE); return false; }
Example #23
Source File: AquaSpinnerUI.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
/** * If the spinner's editor is a DateEditor, this selects the field * associated with the value that is being incremented. */ private void select(final JSpinner spinnerComponent) { final JComponent editor = spinnerComponent.getEditor(); if (!(editor instanceof JSpinner.DateEditor)) return; final JSpinner.DateEditor dateEditor = (JSpinner.DateEditor)editor; final JFormattedTextField ftf = dateEditor.getTextField(); final Format format = dateEditor.getFormat(); Object value; if (format == null || (value = spinnerComponent.getValue()) == null) return; final SpinnerDateModel model = dateEditor.getModel(); final DateFormat.Field field = DateFormat.Field.ofCalendarField(model.getCalendarField()); if (field == null) return; try { final AttributedCharacterIterator iterator = format.formatToCharacterIterator(value); if (!select(ftf, iterator, field) && field == DateFormat.Field.HOUR0) { select(ftf, iterator, DateFormat.Field.HOUR1); } } catch (final IllegalArgumentException iae) {} }
Example #24
Source File: AquaSpinnerUI.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
/** * If the spinner's editor is a DateEditor, this selects the field * associated with the value that is being incremented. */ private void select(final JSpinner spinnerComponent) { final JComponent editor = spinnerComponent.getEditor(); if (!(editor instanceof JSpinner.DateEditor)) return; final JSpinner.DateEditor dateEditor = (JSpinner.DateEditor)editor; final JFormattedTextField ftf = dateEditor.getTextField(); final Format format = dateEditor.getFormat(); Object value; if (format == null || (value = spinnerComponent.getValue()) == null) return; final SpinnerDateModel model = dateEditor.getModel(); final DateFormat.Field field = DateFormat.Field.ofCalendarField(model.getCalendarField()); if (field == null) return; try { final AttributedCharacterIterator iterator = format.formatToCharacterIterator(value); if (!select(ftf, iterator, field) && field == DateFormat.Field.HOUR0) { select(ftf, iterator, DateFormat.Field.HOUR1); } } catch (final IllegalArgumentException iae) {} }
Example #25
Source File: AquaSpinnerUI.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
/** * Selects the passed in field, returning true if it is found, * false otherwise. */ private boolean select(final JFormattedTextField ftf, final AttributedCharacterIterator iterator, final DateFormat.Field field) { final int max = ftf.getDocument().getLength(); iterator.first(); do { final Map<Attribute,Object> attrs = iterator.getAttributes(); if (attrs == null || !attrs.containsKey(field)) continue; final int start = iterator.getRunStart(field); final int end = iterator.getRunLimit(field); if (start != -1 && end != -1 && start <= max && end <= max) { ftf.select(start, end); } return true; } while (iterator.next() != CharacterIterator.DONE); return false; }
Example #26
Source File: AquaSpinnerUI.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
/** * If the spinner's editor is a DateEditor, this selects the field * associated with the value that is being incremented. */ private void select(final JSpinner spinnerComponent) { final JComponent editor = spinnerComponent.getEditor(); if (!(editor instanceof JSpinner.DateEditor)) { return; } final JSpinner.DateEditor dateEditor = (JSpinner.DateEditor) editor; final JFormattedTextField ftf = dateEditor.getTextField(); final Format format = dateEditor.getFormat(); Object value; if (format == null || (value = spinnerComponent.getValue()) == null) { return; } final SpinnerDateModel model = dateEditor.getModel(); final DateFormat.Field field = DateFormat.Field.ofCalendarField(model.getCalendarField()); if (field == null) { return; } try { final AttributedCharacterIterator iterator = format.formatToCharacterIterator(value); if (!select(ftf, iterator, field) && field == DateFormat.Field.HOUR0) { select(ftf, iterator, DateFormat.Field.HOUR1); } } catch (final IllegalArgumentException iae) { } }
Example #27
Source File: AquaSpinnerUI.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 5 votes |
/** * Returns the calendarField under the start of the selection, or * -1 if there is no valid calendar field under the selection (or * the spinner isn't editing dates. */ private int getCalendarField(final JSpinner spinnerComponent) { final JComponent editor = spinnerComponent.getEditor(); if (!(editor instanceof JSpinner.DateEditor)) return -1; final JSpinner.DateEditor dateEditor = (JSpinner.DateEditor)editor; final JFormattedTextField ftf = dateEditor.getTextField(); final int start = ftf.getSelectionStart(); final JFormattedTextField.AbstractFormatter formatter = ftf.getFormatter(); if (!(formatter instanceof InternationalFormatter)) return -1; final Format.Field[] fields = ((InternationalFormatter)formatter).getFields(start); for (final Field element : fields) { if (!(element instanceof DateFormat.Field)) continue; int calendarField; if (element == DateFormat.Field.HOUR1) { calendarField = Calendar.HOUR; } else { calendarField = ((DateFormat.Field)element).getCalendarField(); } if (calendarField != -1) { return calendarField; } } return -1; }
Example #28
Source File: AquaSpinnerUI.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
/** * Returns the calendarField under the start of the selection, or * -1 if there is no valid calendar field under the selection (or * the spinner isn't editing dates. */ private int getCalendarField(final JSpinner spinnerComponent) { final JComponent editor = spinnerComponent.getEditor(); if (!(editor instanceof JSpinner.DateEditor)) return -1; final JSpinner.DateEditor dateEditor = (JSpinner.DateEditor)editor; final JFormattedTextField ftf = dateEditor.getTextField(); final int start = ftf.getSelectionStart(); final JFormattedTextField.AbstractFormatter formatter = ftf.getFormatter(); if (!(formatter instanceof InternationalFormatter)) return -1; final Format.Field[] fields = ((InternationalFormatter)formatter).getFields(start); for (final Field element : fields) { if (!(element instanceof DateFormat.Field)) continue; int calendarField; if (element == DateFormat.Field.HOUR1) { calendarField = Calendar.HOUR; } else { calendarField = ((DateFormat.Field)element).getCalendarField(); } if (calendarField != -1) { return calendarField; } } return -1; }
Example #29
Source File: AquaSpinnerUI.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
/** * Returns the calendarField under the start of the selection, or * -1 if there is no valid calendar field under the selection (or * the spinner isn't editing dates. */ private int getCalendarField(final JSpinner spinnerComponent) { final JComponent editor = spinnerComponent.getEditor(); if (!(editor instanceof JSpinner.DateEditor)) return -1; final JSpinner.DateEditor dateEditor = (JSpinner.DateEditor)editor; final JFormattedTextField ftf = dateEditor.getTextField(); final int start = ftf.getSelectionStart(); final JFormattedTextField.AbstractFormatter formatter = ftf.getFormatter(); if (!(formatter instanceof InternationalFormatter)) return -1; final Format.Field[] fields = ((InternationalFormatter)formatter).getFields(start); for (final Field element : fields) { if (!(element instanceof DateFormat.Field)) continue; int calendarField; if (element == DateFormat.Field.HOUR1) { calendarField = Calendar.HOUR; } else { calendarField = ((DateFormat.Field)element).getCalendarField(); } if (calendarField != -1) { return calendarField; } } return -1; }
Example #30
Source File: AquaSpinnerUI.java From jdk8u_jdk with GNU General Public License v2.0 | 5 votes |
/** * Returns the calendarField under the start of the selection, or * -1 if there is no valid calendar field under the selection (or * the spinner isn't editing dates. */ private int getCalendarField(final JSpinner spinnerComponent) { final JComponent editor = spinnerComponent.getEditor(); if (!(editor instanceof JSpinner.DateEditor)) return -1; final JSpinner.DateEditor dateEditor = (JSpinner.DateEditor)editor; final JFormattedTextField ftf = dateEditor.getTextField(); final int start = ftf.getSelectionStart(); final JFormattedTextField.AbstractFormatter formatter = ftf.getFormatter(); if (!(formatter instanceof InternationalFormatter)) return -1; final Format.Field[] fields = ((InternationalFormatter)formatter).getFields(start); for (final Field element : fields) { if (!(element instanceof DateFormat.Field)) continue; int calendarField; if (element == DateFormat.Field.HOUR1) { calendarField = Calendar.HOUR; } else { calendarField = ((DateFormat.Field)element).getCalendarField(); } if (calendarField != -1) { return calendarField; } } return -1; }