01: /*
02: * Copyright Javelin Software, All rights reserved.
03: */
04:
05: package com.javelin.swinglets;
06:
07: import java.awt.*;
08: import java.awt.event.*;
09: import java.util.*;
10: import java.io.*;
11:
12: import com.javelin.swinglets.plaf.*;
13:
14: /**
15: * STextField defines an text field.
16: *
17: * @author Robin Sharp
18: */
19:
20: public abstract class STextComponent extends SComponent {
21: /**
22: * Creates a STextComponent with the following text.
23: */
24: public STextComponent(String text) {
25: this .text = text;
26: }
27:
28: /**
29: * Creates a STextComponent.
30: */
31: public STextComponent() {
32: }
33:
34: /**
35: * Returns the name of the L&F class that renders this component.
36: */
37: public Class getUIClass() {
38: return STextComponent.class;
39: }
40:
41: /**
42: * Set the value as Text. This sets the text property.
43: */
44: public SComponent setValueAsText(String text) {
45: setText(text);
46: return this ;
47: }
48:
49: /**
50: * Get the text.
51: */
52: public String getText() {
53: return text;
54: }
55:
56: /**
57: * Set the text.
58: */
59: public STextComponent setText(String text) {
60: this .text = text;
61: return this ;
62: }
63:
64: /**
65: * Append some text.
66: */
67: public void appendText(String text) {
68: if (getText() == null)
69: setText(text);
70: else
71: setText(getText() + text);
72: }
73:
74: // DISPATCH & EVENTS //////////////////////////////////////////////////////
75:
76: /**
77: * Adds the specified text event listener to recieve text events
78: * from this textcomponent.
79: */
80: public STextComponent addTextListener(TextListener listener) {
81: getUI().addListener(listener);
82: return this ;
83: }
84:
85: /**
86: * Removes the specified text event listener so that it no longer
87: * receives text events from this textcomponent.
88: */
89: public STextComponent removeTextListener(TextListener listener) {
90: getUI().removeListener(listener);
91: return this ;
92: }
93:
94: // PRIVATE /////////////////////////////////////////////////////////////
95:
96: protected String text;
97:
98: }
|