modules/controls/src/main/java/javafx/scene/control/Spinner.java

Print this page
rev 9240 : 8076423: JEP 253: Prepare JavaFX UI Controls & CSS APIs for Modularization


   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
  23  * questions.
  24  */
  25 package javafx.scene.control;
  26 
  27 import com.sun.javafx.scene.control.skin.ComboBoxListViewSkin;
  28 import com.sun.javafx.scene.control.skin.SpinnerSkin;

  29 import javafx.beans.NamedArg;
  30 import javafx.beans.property.BooleanProperty;
  31 import javafx.beans.property.ObjectProperty;
  32 import javafx.beans.property.ReadOnlyObjectProperty;
  33 import javafx.beans.property.ReadOnlyObjectWrapper;
  34 import javafx.beans.property.SimpleBooleanProperty;
  35 import javafx.beans.property.SimpleObjectProperty;
  36 import javafx.collections.MapChangeListener;
  37 import javafx.collections.ObservableList;
  38 import javafx.scene.AccessibleAction;
  39 import javafx.scene.AccessibleAttribute;
  40 import javafx.scene.AccessibleRole;
  41 import javafx.util.StringConverter;
  42 
  43 import java.math.BigDecimal;
  44 import java.time.LocalDate;
  45 import java.time.LocalTime;
  46 import java.time.temporal.TemporalUnit;
  47 
  48 /**


 524     public final void setEditable(boolean value) {
 525         editableProperty().set(value);
 526     }
 527     public final boolean isEditable() {
 528         return editable == null ? true : editable.get();
 529     }
 530     public final BooleanProperty editableProperty() {
 531         if (editable == null) {
 532             editable = new SimpleBooleanProperty(this, "editable", false);
 533         }
 534         return editable;
 535     }
 536 
 537 
 538     // --- editor
 539     /**
 540      * The editor used by the Spinner control.
 541      */
 542     public final ReadOnlyObjectProperty<TextField> editorProperty() {
 543         if (editor == null) {
 544             editor = new ReadOnlyObjectWrapper<TextField>(this, "editor");
 545             textField = new ComboBoxListViewSkin.FakeFocusTextField();
 546             editor.set(textField);
 547         }
 548         return editor.getReadOnlyProperty();
 549     }
 550     private TextField textField;
 551     private ReadOnlyObjectWrapper<TextField> editor;
 552     public final TextField getEditor() {
 553         return editorProperty().get();
 554     }
 555 
 556 
 557 
 558     /***************************************************************************
 559      *                                                                         *
 560      * Implementation                                                          *
 561      *                                                                         *
 562      **************************************************************************/
 563 
 564     /*
 565      * Update the TextField based on the current value




   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
  23  * questions.
  24  */
  25 package javafx.scene.control;
  26 
  27 import com.sun.javafx.scene.control.FakeFocusTextField;
  28 import javafx.scene.control.skin.ComboBoxListViewSkin;
  29 import javafx.scene.control.skin.SpinnerSkin;
  30 import javafx.beans.NamedArg;
  31 import javafx.beans.property.BooleanProperty;
  32 import javafx.beans.property.ObjectProperty;
  33 import javafx.beans.property.ReadOnlyObjectProperty;
  34 import javafx.beans.property.ReadOnlyObjectWrapper;
  35 import javafx.beans.property.SimpleBooleanProperty;
  36 import javafx.beans.property.SimpleObjectProperty;
  37 import javafx.collections.MapChangeListener;
  38 import javafx.collections.ObservableList;
  39 import javafx.scene.AccessibleAction;
  40 import javafx.scene.AccessibleAttribute;
  41 import javafx.scene.AccessibleRole;
  42 import javafx.util.StringConverter;
  43 
  44 import java.math.BigDecimal;
  45 import java.time.LocalDate;
  46 import java.time.LocalTime;
  47 import java.time.temporal.TemporalUnit;
  48 
  49 /**


 525     public final void setEditable(boolean value) {
 526         editableProperty().set(value);
 527     }
 528     public final boolean isEditable() {
 529         return editable == null ? true : editable.get();
 530     }
 531     public final BooleanProperty editableProperty() {
 532         if (editable == null) {
 533             editable = new SimpleBooleanProperty(this, "editable", false);
 534         }
 535         return editable;
 536     }
 537 
 538 
 539     // --- editor
 540     /**
 541      * The editor used by the Spinner control.
 542      */
 543     public final ReadOnlyObjectProperty<TextField> editorProperty() {
 544         if (editor == null) {
 545             editor = new ReadOnlyObjectWrapper<>(this, "editor");
 546             textField = new FakeFocusTextField();
 547             editor.set(textField);
 548         }
 549         return editor.getReadOnlyProperty();
 550     }
 551     private TextField textField;
 552     private ReadOnlyObjectWrapper<TextField> editor;
 553     public final TextField getEditor() {
 554         return editorProperty().get();
 555     }
 556 
 557 
 558 
 559     /***************************************************************************
 560      *                                                                         *
 561      * Implementation                                                          *
 562      *                                                                         *
 563      **************************************************************************/
 564 
 565     /*
 566      * Update the TextField based on the current value