home *** CD-ROM | disk | FTP | other *** search
Java Source | 1997-07-30 | 1.6 KB | 76 lines |
- package borland.samples.intl.beans;
-
- import java.text.*;
-
- public class InternationalClockDisplayStyleEditor
- extends java.beans.PropertyEditorSupport {
-
- int style;
-
- public String[] getTags() {
- String result[] = {
- "DEFAULT",
- "SHORT",
- "MEDIUM",
- "LONG",
- "FULL",
- };
- return result;
- }
-
- public String getJavaInitializationString() {
- switch (style) {
- case DateFormat.SHORT:
- return "java.text.DateFormat.SHORT";
- case DateFormat.MEDIUM:
- return "java.text.DateFormat.MEDIUM";
- case DateFormat.LONG:
- return "java.text.DateFormat.LONG";
- case DateFormat.FULL:
- return "java.text.DateFormat.FULL";
- default:
- return "java.text.DateFormat.DEFAULT";
- }
- }
-
- public void setAsText(String text) {
- if (text.equals("SHORT")) {
- style = DateFormat.SHORT;
- } else if (text.equals("MEDIUM")) {
- style = DateFormat.MEDIUM;
- } else if (text.equals("LONG")) {
- style = DateFormat.LONG;
- } else if (text.equals("FULL")) {
- style = DateFormat.FULL;
- } else {
- style = DateFormat.DEFAULT;
- }
- }
-
- public String getAsText() {
- switch (style) {
- case DateFormat.SHORT:
- return "SHORT";
- case DateFormat.MEDIUM:
- return "MEDIUM";
- case DateFormat.LONG:
- return "LONG";
- case DateFormat.FULL:
- return "FULL";
- default:
- return "DEFAULT";
- }
- }
-
- public void setValue(Object o) {
- style = ((Integer) o).intValue();
- firePropertyChange();
- }
-
- public Object getValue() {
- return new Integer(style);
- }
-
- }
-
-