01: /*
02: * Copyright Javelin Software, All rights reserved.
03: */
04:
05: package com.javelin.swinglets.plaf.wml;
06:
07: import java.awt.*;
08: import java.util.*;
09: import java.io.*;
10:
11: import com.javelin.swinglets.*;
12: import com.javelin.swinglets.plaf.*;
13: import com.javelin.swinglets.plaf.html.*;
14:
15: /**
16: * WMLTextFieldUI defines a look and feel for default WML.
17: * <p>
18: * This class performs a object.toString for the client property "wml.format"
19: * to format the text field. If in addition is the "wml.emptyok" property is set
20: * empty formatted fields can be entered.
21: * <P>
22: * The tooltiptext is used to set the title.
23: *
24: * @author Robin Sharp
25: */
26:
27: public class WMLTextFieldUI extends WMLTextComponentUI {
28: /**
29: * Render the UI on the PrintWriter
30: */
31: public void update(PrintWriter out, SComponent c) {
32: if (!c.isVisible())
33: return;
34:
35: STextField textField = (STextField) c;
36:
37: out.print("<input");
38:
39: if (textField.getName() != null) {
40: out.print(" name=\"");
41: out.print(textField.getName());
42: out.print("\"");
43: }
44:
45: out.print(" type=\"text\"");
46:
47: if (textField.getText() != null) {
48: out.print(" value=\"");
49: out.print(textField.getText());
50: out.print("\"");
51: }
52:
53: Object format = textField.getClientProperty("wml.format");
54: if (format != null) {
55: out.print(" format=\"");
56: out.print(format.toString());
57: out.print("\"");
58: }
59:
60: format = textField.getClientProperty("wml.emptyok");
61: if (format != null) {
62: out.print(" emptyok=\"true");
63: }
64:
65: if (textField.getSize() != null
66: && textField.getSize().width > 0) {
67: out.print(" size=\"");
68: out.print(textField.getSize().width);
69: out.print("\"");
70: }
71:
72: if (textField.getMaxLength() > 0) {
73: out.print(" maxlength=\"");
74: out.print(textField.getMaxLength());
75: out.print("\"");
76: }
77:
78: if (textField.getToolTipText() != null) {
79: out.print(" title=\"");
80: out.print(textField.getToolTipText());
81: out.print("\"");
82: }
83:
84: out.println("/>");
85: }
86: }
|