1 /*
2 * Copyright (c) 2000, 2006, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
634 else if (!isEdited()) {
635 // reformat
636 setValue(getValue(), true, true);
637 }
638 }
639
640 /**
641 * FOCUS_LOST behavior implementation
642 */
643 private class FocusLostHandler implements Runnable, Serializable {
644 public void run() {
645 int fb = JFormattedTextField.this.getFocusLostBehavior();
646 if (fb == JFormattedTextField.COMMIT ||
647 fb == JFormattedTextField.COMMIT_OR_REVERT) {
648 try {
649 JFormattedTextField.this.commitEdit();
650 // Give it a chance to reformat.
651 JFormattedTextField.this.setValue(
652 JFormattedTextField.this.getValue(), true, true);
653 } catch (ParseException pe) {
654 if (fb == JFormattedTextField.this.COMMIT_OR_REVERT) {
655 JFormattedTextField.this.setValue(
656 JFormattedTextField.this.getValue(), true, true);
657 }
658 }
659 }
660 else if (fb == JFormattedTextField.REVERT) {
661 JFormattedTextField.this.setValue(
662 JFormattedTextField.this.getValue(), true, true);
663 }
664 }
665 }
666
667 /**
668 * Fetches the command list for the editor. This is
669 * the list of commands supported by the plugged-in UI
670 * augmented by the collection of commands that the
671 * editor itself supports. These are useful for binding
672 * to events, such as in a keymap.
673 *
674 * @return the command list
|
1 /*
2 * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
634 else if (!isEdited()) {
635 // reformat
636 setValue(getValue(), true, true);
637 }
638 }
639
640 /**
641 * FOCUS_LOST behavior implementation
642 */
643 private class FocusLostHandler implements Runnable, Serializable {
644 public void run() {
645 int fb = JFormattedTextField.this.getFocusLostBehavior();
646 if (fb == JFormattedTextField.COMMIT ||
647 fb == JFormattedTextField.COMMIT_OR_REVERT) {
648 try {
649 JFormattedTextField.this.commitEdit();
650 // Give it a chance to reformat.
651 JFormattedTextField.this.setValue(
652 JFormattedTextField.this.getValue(), true, true);
653 } catch (ParseException pe) {
654 if (fb == JFormattedTextField.COMMIT_OR_REVERT) {
655 JFormattedTextField.this.setValue(
656 JFormattedTextField.this.getValue(), true, true);
657 }
658 }
659 }
660 else if (fb == JFormattedTextField.REVERT) {
661 JFormattedTextField.this.setValue(
662 JFormattedTextField.this.getValue(), true, true);
663 }
664 }
665 }
666
667 /**
668 * Fetches the command list for the editor. This is
669 * the list of commands supported by the plugged-in UI
670 * augmented by the collection of commands that the
671 * editor itself supports. These are useful for binding
672 * to events, such as in a keymap.
673 *
674 * @return the command list
|