src/share/classes/javax/swing/JSpinner.java

Print this page




 890         }
 891 
 892         /**
 893          * Returns an enum indicating how the baseline of the component
 894          * changes as the size changes.
 895          *
 896          * @throws NullPointerException {@inheritDoc}
 897          * @see javax.swing.JComponent#getBaseline(int, int)
 898          * @since 1.6
 899          */
 900         public BaselineResizeBehavior getBaselineResizeBehavior() {
 901             return getComponent(0).getBaselineResizeBehavior();
 902         }
 903     }
 904 
 905 
 906 
 907 
 908     /**
 909      * This subclass of javax.swing.DateFormatter maps the minimum/maximum
 910      * properties to te start/end properties of a SpinnerDateModel.
 911      */
 912     private static class DateEditorFormatter extends DateFormatter {
 913         private final SpinnerDateModel model;
 914 
 915         DateEditorFormatter(SpinnerDateModel model, DateFormat format) {
 916             super(format);
 917             this.model = model;
 918         }
 919 
 920         public void setMinimum(Comparable min) {
 921             model.setStart(min);


 922         }
 923 
 924         public Comparable getMinimum() {

 925             return  model.getStart();
 926         }
 927 
 928         public void setMaximum(Comparable max) {
 929             model.setEnd(max);


 930         }
 931 
 932         public Comparable getMaximum() {

 933             return model.getEnd();
 934         }
 935     }
 936 
 937 
 938     /**
 939      * An editor for a <code>JSpinner</code> whose model is a
 940      * <code>SpinnerDateModel</code>.  The value of the editor is
 941      * displayed with a <code>JFormattedTextField</code> whose format
 942      * is defined by a <code>DateFormatter</code> instance whose
 943      * <code>minimum</code> and <code>maximum</code> properties
 944      * are mapped to the <code>SpinnerDateModel</code>.
 945      * @since 1.4
 946      */
 947     // PENDING(hmuller): more example javadoc
 948     public static class DateEditor extends DefaultEditor
 949     {
 950         // This is here until SimpleDateFormat gets a constructor that
 951         // takes a Locale: 4923525
 952         private static String getDefaultPattern(Locale loc) {


1078         public SpinnerDateModel getModel() {
1079             return (SpinnerDateModel)(getSpinner().getModel());
1080         }
1081     }
1082 
1083 
1084     /**
1085      * This subclass of javax.swing.NumberFormatter maps the minimum/maximum
1086      * properties to a SpinnerNumberModel and initializes the valueClass
1087      * of the NumberFormatter to match the type of the initial models value.
1088      */
1089     private static class NumberEditorFormatter extends NumberFormatter {
1090         private final SpinnerNumberModel model;
1091 
1092         NumberEditorFormatter(SpinnerNumberModel model, NumberFormat format) {
1093             super(format);
1094             this.model = model;
1095             setValueClass(model.getValue().getClass());
1096         }
1097 
1098         public void setMinimum(Comparable min) {

1099             model.setMinimum(min);
1100         }
1101 
1102         public Comparable getMinimum() {

1103             return  model.getMinimum();
1104         }
1105 
1106         public void setMaximum(Comparable max) {

1107             model.setMaximum(max);
1108         }
1109 
1110         public Comparable getMaximum() {

1111             return model.getMaximum();
1112         }
1113     }
1114 
1115 
1116 
1117     /**
1118      * An editor for a <code>JSpinner</code> whose model is a
1119      * <code>SpinnerNumberModel</code>.  The value of the editor is
1120      * displayed with a <code>JFormattedTextField</code> whose format
1121      * is defined by a <code>NumberFormatter</code> instance whose
1122      * <code>minimum</code> and <code>maximum</code> properties
1123      * are mapped to the <code>SpinnerNumberModel</code>.
1124      * @since 1.4
1125      */
1126     // PENDING(hmuller): more example javadoc
1127     public static class NumberEditor extends DefaultEditor
1128     {
1129         // This is here until DecimalFormat gets a constructor that
1130         // takes a Locale: 4923525




 890         }
 891 
 892         /**
 893          * Returns an enum indicating how the baseline of the component
 894          * changes as the size changes.
 895          *
 896          * @throws NullPointerException {@inheritDoc}
 897          * @see javax.swing.JComponent#getBaseline(int, int)
 898          * @since 1.6
 899          */
 900         public BaselineResizeBehavior getBaselineResizeBehavior() {
 901             return getComponent(0).getBaselineResizeBehavior();
 902         }
 903     }
 904 
 905 
 906 
 907 
 908     /**
 909      * This subclass of javax.swing.DateFormatter maps the minimum/maximum
 910      * properties to the start/end properties of a SpinnerDateModel.
 911      */
 912     private static class DateEditorFormatter extends DateFormatter {
 913         private final SpinnerDateModel model;
 914 
 915         DateEditorFormatter(SpinnerDateModel model, DateFormat format) {
 916             super(format);
 917             this.model = model;
 918         }
 919 
 920         @Override
 921         @SuppressWarnings("unchecked")
 922         public void setMinimum(Comparable<?> min) {
 923             model.setStart((Comparable<Date>)min);
 924         }
 925 
 926         @Override
 927         public Comparable<Date> getMinimum() {
 928             return  model.getStart();
 929         }
 930 
 931         @Override
 932         @SuppressWarnings("unchecked")
 933         public void setMaximum(Comparable<?> max) {
 934             model.setEnd((Comparable<Date>)max);
 935         }
 936 
 937         @Override
 938         public Comparable<Date> getMaximum() {
 939             return model.getEnd();
 940         }
 941     }
 942 
 943 
 944     /**
 945      * An editor for a <code>JSpinner</code> whose model is a
 946      * <code>SpinnerDateModel</code>.  The value of the editor is
 947      * displayed with a <code>JFormattedTextField</code> whose format
 948      * is defined by a <code>DateFormatter</code> instance whose
 949      * <code>minimum</code> and <code>maximum</code> properties
 950      * are mapped to the <code>SpinnerDateModel</code>.
 951      * @since 1.4
 952      */
 953     // PENDING(hmuller): more example javadoc
 954     public static class DateEditor extends DefaultEditor
 955     {
 956         // This is here until SimpleDateFormat gets a constructor that
 957         // takes a Locale: 4923525
 958         private static String getDefaultPattern(Locale loc) {


1084         public SpinnerDateModel getModel() {
1085             return (SpinnerDateModel)(getSpinner().getModel());
1086         }
1087     }
1088 
1089 
1090     /**
1091      * This subclass of javax.swing.NumberFormatter maps the minimum/maximum
1092      * properties to a SpinnerNumberModel and initializes the valueClass
1093      * of the NumberFormatter to match the type of the initial models value.
1094      */
1095     private static class NumberEditorFormatter extends NumberFormatter {
1096         private final SpinnerNumberModel model;
1097 
1098         NumberEditorFormatter(SpinnerNumberModel model, NumberFormat format) {
1099             super(format);
1100             this.model = model;
1101             setValueClass(model.getValue().getClass());
1102         }
1103 
1104         @Override
1105         public void setMinimum(Comparable<?> min) {
1106             model.setMinimum(min);
1107         }
1108 
1109         @Override
1110         public Comparable<?> getMinimum() {
1111             return  model.getMinimum();
1112         }
1113 
1114         @Override
1115         public void setMaximum(Comparable<?> max) {
1116             model.setMaximum(max);
1117         }
1118 
1119         @Override
1120         public Comparable<?> getMaximum() {
1121             return model.getMaximum();
1122         }
1123     }
1124 
1125 
1126 
1127     /**
1128      * An editor for a <code>JSpinner</code> whose model is a
1129      * <code>SpinnerNumberModel</code>.  The value of the editor is
1130      * displayed with a <code>JFormattedTextField</code> whose format
1131      * is defined by a <code>NumberFormatter</code> instance whose
1132      * <code>minimum</code> and <code>maximum</code> properties
1133      * are mapped to the <code>SpinnerNumberModel</code>.
1134      * @since 1.4
1135      */
1136     // PENDING(hmuller): more example javadoc
1137     public static class NumberEditor extends DefaultEditor
1138     {
1139         // This is here until DecimalFormat gets a constructor that
1140         // takes a Locale: 4923525