690 select(ftf, iterator, DateFormat.Field.HOUR1);
691 }
692 }
693 catch (IllegalArgumentException iae) {}
694 }
695 }
696 }
697 }
698
699 /**
700 * Selects the passed in field, returning true if it is found,
701 * false otherwise.
702 */
703 private boolean select(JFormattedTextField ftf,
704 AttributedCharacterIterator iterator,
705 DateFormat.Field field) {
706 int max = ftf.getDocument().getLength();
707
708 iterator.first();
709 do {
710 Map attrs = iterator.getAttributes();
711
712 if (attrs != null && attrs.containsKey(field)){
713 int start = iterator.getRunStart(field);
714 int end = iterator.getRunLimit(field);
715
716 if (start != -1 && end != -1 && start <= max &&
717 end <= max) {
718 ftf.select(start, end);
719 }
720 return true;
721 }
722 } while (iterator.next() != CharacterIterator.DONE);
723 return false;
724 }
725
726 /**
727 * Returns the calendarField under the start of the selection, or
728 * -1 if there is no valid calendar field under the selection (or
729 * the spinner isn't editing dates.
730 */
|
690 select(ftf, iterator, DateFormat.Field.HOUR1);
691 }
692 }
693 catch (IllegalArgumentException iae) {}
694 }
695 }
696 }
697 }
698
699 /**
700 * Selects the passed in field, returning true if it is found,
701 * false otherwise.
702 */
703 private boolean select(JFormattedTextField ftf,
704 AttributedCharacterIterator iterator,
705 DateFormat.Field field) {
706 int max = ftf.getDocument().getLength();
707
708 iterator.first();
709 do {
710 Map<?, ?> attrs = iterator.getAttributes();
711
712 if (attrs != null && attrs.containsKey(field)){
713 int start = iterator.getRunStart(field);
714 int end = iterator.getRunLimit(field);
715
716 if (start != -1 && end != -1 && start <= max &&
717 end <= max) {
718 ftf.select(start, end);
719 }
720 return true;
721 }
722 } while (iterator.next() != CharacterIterator.DONE);
723 return false;
724 }
725
726 /**
727 * Returns the calendarField under the start of the selection, or
728 * -1 if there is no valid calendar field under the selection (or
729 * the spinner isn't editing dates.
730 */
|