Skip to content

Commit 7664c0f

Browse files
hansonrhansonr
authored andcommitted
JSSpinnerUI replace with *original* Java8 version.
Works perfectly!!
1 parent 1437a63 commit 7664c0f

File tree

15 files changed

+1863
-736
lines changed

15 files changed

+1863
-736
lines changed

sources/net.sf.j2s.java.core/src/javax/swing/JSpinner.java

Lines changed: 191 additions & 188 deletions
Large diffs are not rendered by default.

sources/net.sf.j2s.java.core/src/javax/swing/text/DateFormatter.java

Lines changed: 116 additions & 116 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,13 @@
2727
*/
2828
package javax.swing.text;
2929

30-
//TODO import java.text.DateFormat;
31-
//import java.text.Format;
32-
//import java.text.ParseException;
33-
//import java.util.Calendar;
34-
//import java.util.Date;
35-
//import java.util.Iterator;
36-
//import java.util.Map;
30+
import java.text.DateFormat;
31+
import java.text.Format;
32+
import java.text.ParseException;
33+
import java.util.Calendar;
34+
import java.util.Date;
35+
import java.util.Iterator;
36+
import java.util.Map;
3737

3838
/**
3939
* DateFormatter is an <code>InternationalFormatter</code> that does its
@@ -53,113 +53,113 @@
5353
* @since 1.4
5454
*/
5555
public class DateFormatter extends InternationalFormatter {
56-
// /**
57-
// * This is shorthand for
58-
// * <code>new DateFormatter(DateFormat.getDateInstance())</code>.
59-
// */
60-
// public DateFormatter() {
61-
// this(DateFormat.getDateInstance());
62-
// }
63-
//
64-
// /**
65-
// * Returns a DateFormatter configured with the specified
66-
// * <code>Format</code> instance.
67-
// *
68-
// * @param format Format used to dictate legal values
69-
// */
70-
// public DateFormatter(DateFormat format) {
71-
// super(format);
72-
// setFormat(format);
73-
// }
74-
//
75-
// /**
76-
// * Sets the format that dictates the legal values that can be edited
77-
// * and displayed.
78-
// * <p>
79-
// * If you have used the nullary constructor the value of this property
80-
// * will be determined for the current locale by way of the
81-
// * <code>Dateformat.getDateInstance()</code> method.
82-
// *
83-
// * @param format DateFormat instance used for converting from/to Strings
84-
// */
85-
// public void setFormat(DateFormat format) {
86-
// super.setFormat(format);
87-
// }
88-
//
89-
// /**
90-
// * Returns the Calendar that <code>DateFormat</code> is associated with,
91-
// * or if the <code>Format</code> is not a <code>DateFormat</code>
92-
// * <code>Calendar.getInstance</code> is returned.
93-
// */
94-
// private Calendar getCalendar() {
95-
// Format f = getFormat();
96-
//
97-
// if (f instanceof DateFormat) {
98-
// return ((DateFormat)f).getCalendar();
99-
// }
100-
// return Calendar.getInstance();
101-
// }
102-
//
103-
//
104-
// /**
105-
// * Returns true, as DateFormatterFilter will support
106-
// * incrementing/decrementing of the value.
107-
// */
108-
// boolean getSupportsIncrement() {
109-
// return true;
110-
// }
111-
//
112-
// /**
113-
// * Returns the field that will be adjusted by adjustValue.
114-
// */
115-
// Object getAdjustField(int start, Map attributes) {
116-
// Iterator attrs = attributes.keySet().iterator();
117-
//
118-
// while (attrs.hasNext()) {
119-
// Object key = attrs.next();
120-
//
121-
// if ((key instanceof DateFormat.Field) &&
122-
// (key == DateFormat.Field.HOUR1 ||
123-
// ((DateFormat.Field)key).getCalendarField() != -1)) {
124-
// return key;
125-
// }
126-
// }
127-
// return null;
128-
// }
129-
//
130-
// /**
131-
// * Adjusts the Date if FieldPosition identifies a known calendar
132-
// * field.
133-
// */
134-
// Object adjustValue(Object value, Map attributes, Object key,
135-
// int direction) throws
136-
// BadLocationException, ParseException {
137-
// if (key != null) {
138-
// int field;
139-
//
140-
// // HOUR1 has no corresponding calendar field, thus, map
141-
// // it to HOUR0 which will give the correct behavior.
142-
// if (key == DateFormat.Field.HOUR1) {
143-
// key = DateFormat.Field.HOUR0;
144-
// }
145-
// field = ((DateFormat.Field)key).getCalendarField();
146-
//
147-
// Calendar calendar = getCalendar();
148-
//
149-
// if (calendar != null) {
150-
// calendar.setTime((Date)value);
151-
//
152-
// int fieldValue = calendar.get(field);
153-
//
154-
// try {
155-
// calendar.add(field, direction);
156-
// value = calendar.getTime();
157-
// } catch (Throwable th) {
158-
// value = null;
159-
// }
160-
// return value;
161-
// }
162-
// }
163-
// return null;
164-
// }
56+
/**
57+
* This is shorthand for
58+
* <code>new DateFormatter(DateFormat.getDateInstance())</code>.
59+
*/
60+
public DateFormatter() {
61+
this(DateFormat.getDateInstance());
62+
}
63+
64+
/**
65+
* Returns a DateFormatter configured with the specified
66+
* <code>Format</code> instance.
67+
*
68+
* @param format Format used to dictate legal values
69+
*/
70+
public DateFormatter(DateFormat format) {
71+
super(format);
72+
setFormat(format);
73+
}
74+
75+
/**
76+
* Sets the format that dictates the legal values that can be edited
77+
* and displayed.
78+
* <p>
79+
* If you have used the nullary constructor the value of this property
80+
* will be determined for the current locale by way of the
81+
* <code>Dateformat.getDateInstance()</code> method.
82+
*
83+
* @param format DateFormat instance used for converting from/to Strings
84+
*/
85+
public void setFormat(DateFormat format) {
86+
super.setFormat(format);
87+
}
88+
89+
/**
90+
* Returns the Calendar that <code>DateFormat</code> is associated with,
91+
* or if the <code>Format</code> is not a <code>DateFormat</code>
92+
* <code>Calendar.getInstance</code> is returned.
93+
*/
94+
private Calendar getCalendar() {
95+
Format f = getFormat();
96+
97+
if (f instanceof DateFormat) {
98+
return ((DateFormat)f).getCalendar();
99+
}
100+
return Calendar.getInstance();
101+
}
102+
103+
104+
/**
105+
* Returns true, as DateFormatterFilter will support
106+
* incrementing/decrementing of the value.
107+
*/
108+
boolean getSupportsIncrement() {
109+
return true;
110+
}
111+
112+
/**
113+
* Returns the field that will be adjusted by adjustValue.
114+
*/
115+
Object getAdjustField(int start, Map attributes) {
116+
Iterator attrs = attributes.keySet().iterator();
117+
118+
while (attrs.hasNext()) {
119+
Object key = attrs.next();
120+
121+
if ((key instanceof DateFormat.Field) &&
122+
(key == DateFormat.Field.HOUR1 ||
123+
((DateFormat.Field)key).getCalendarField() != -1)) {
124+
return key;
125+
}
126+
}
127+
return null;
128+
}
129+
130+
/**
131+
* Adjusts the Date if FieldPosition identifies a known calendar
132+
* field.
133+
*/
134+
Object adjustValue(Object value, Map attributes, Object key,
135+
int direction) throws
136+
BadLocationException, ParseException {
137+
if (key != null) {
138+
int field;
139+
140+
// HOUR1 has no corresponding calendar field, thus, map
141+
// it to HOUR0 which will give the correct behavior.
142+
if (key == DateFormat.Field.HOUR1) {
143+
key = DateFormat.Field.HOUR0;
144+
}
145+
field = ((DateFormat.Field)key).getCalendarField();
146+
147+
Calendar calendar = getCalendar();
148+
149+
if (calendar != null) {
150+
calendar.setTime((Date)value);
151+
152+
int fieldValue = calendar.get(field);
153+
154+
try {
155+
calendar.add(field, direction);
156+
value = calendar.getTime();
157+
} catch (Throwable th) {
158+
value = null;
159+
}
160+
return value;
161+
}
162+
}
163+
return null;
164+
}
165165
}

sources/net.sf.j2s.java.core/src/swingjs/jquery/JQueryUI.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@
99
*
1010
* @author Bob Hanson
1111
*
12-
*
12+
*
1313
*/
1414
public class JQueryUI {
1515

16-
public JQueryUI() {
16+
public JQueryUI() {
1717
// for reflection
1818
}
1919
static {

0 commit comments

Comments
 (0)