home *** CD-ROM | disk | FTP | other *** search
Java Source | 1998-05-08 | 2.5 KB | 95 lines |
- /*
- * Copyright (c) 1997-1998 Borland International, Inc. All Rights Reserved.
- *
- * This SOURCE CODE FILE, which has been provided by Borland as part
- * of a Borland product for use ONLY by licensed users of the product,
- * includes CONFIDENTIAL and PROPRIETARY information of Borland.
- *
- * USE OF THIS SOFTWARE IS GOVERNED BY THE TERMS AND CONDITIONS
- * OF THE LICENSE STATEMENT AND LIMITED WARRANTY FURNISHED WITH
- * THE PRODUCT.
- *
- * IN PARTICULAR, YOU WILL INDEMNIFY AND HOLD BORLAND, ITS RELATED
- * COMPANIES AND ITS SUPPLIERS, HARMLESS FROM AND AGAINST ANY CLAIMS
- * OR LIABILITIES ARISING OUT OF THE USE, REPRODUCTION, OR DISTRIBUTION
- * OF YOUR PROGRAMS, INCLUDING ANY CLAIMS OR LIABILITIES ARISING OUT OF
- * OR RESULTING FROM THE USE, MODIFICATION, OR DISTRIBUTION OF PROGRAMS
- * OR FILES CREATED FROM, BASED ON, AND/OR DERIVED FROM THIS SOURCE
- * CODE FILE.
- */
- 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);
- }
-
- }
-
-