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.awt.event.*;
09: import java.util.*;
10: import java.io.*;
11:
12: import com.javelin.swinglets.*;
13: import com.javelin.swinglets.plaf.*;
14:
15: /**
16: * WMLComboBoxUI defines a look and feel for default WML.
17: *
18: * @author Robin Sharp
19: */
20:
21: public class WMLComboBoxUI extends WMLComponentUI {
22: /**
23: * Render the UI on the PrintWriter
24: */
25: public void update(PrintWriter out, SComponent c) {
26: if (!c.isVisible())
27: return;
28:
29: SComboBox combo = (SComboBox) c;
30:
31: out.print("<select name=\"");
32: out.print(combo.getName());
33: out.print("\"");
34:
35: if (combo.getSelectedIndex() >= 0) {
36: out.print(" ivalue=\"");
37: out.print(combo.getSelectedIndex() + 1);
38: out.print("\"");
39: }
40:
41: if (combo.getToolTipText() != null) {
42: out.print(" title=\"");
43: out.print(combo.getToolTipText());
44: out.print("\"");
45: }
46:
47: out.print(">");
48:
49: for (int index = 0; index < combo.getItemCount(); index++) {
50: //If the combo is disabled - only allow the selection of one option
51: if (combo.isEnabled() == false) {
52: if (index == combo.getSelectedIndex()) {
53: out.print("<option value=\"");
54: out.print(index);
55: out.print("\">");
56: out.print(combo.getItemAt(index).toString());
57: out.println("</option>");
58: break;
59: }
60: } else {
61: out.print("<option value=\"");
62: out.print(index);
63: out.print("\">");
64: out.print(combo.getItemAt(index).toString());
65: out.println("</option>");
66: }
67: }
68:
69: out.println("</select>");
70: }
71:
72: }
|