DEADSOFTWARE

Update readme
[mp3cc.git] / mps / src / FS.java
1 /*
2 * This class is used when Forms support is needeed
3 * */
4 import javax.microedition.lcdui.*;
6 public class FS
7 {
8 /* add a textfiled into the form */
9 public static int Lj(String label, String text,
10 int maxSize, int constraints)
11 {
12 try
13 {
14 return FW.F.append(new TextField(label, text, maxSize, constraints));
15 }
16 catch (Exception E)
17 {
18 return -1;
19 }
20 }
22 /* add gauge */
23 public static int Lj(String label, int interactive,
24 int maxValue, int initialValue)
25 {
26 try
27 {
28 boolean inter = true;
29 if (interactive == 0)
30 inter = false;
31 // j-a-s-d: avoid AV false alarm
32 return FW.F.append(new Gauge(label, inter, maxValue, initialValue));
33 }
34 catch (Exception E)
35 {
36 return -1;
37 }
38 }
40 /* add choice group */
41 public static int Lj(String label, int type)
42 {
43 try
44 {
45 ChoiceGroup cg = new ChoiceGroup(label, type);
46 return FW.F.append(cg);
47 }
48 catch (Exception E)
49 {
50 return -1;
51 }
52 }
54 /* get int value from gauge */
55 public static int Lja(int itemNum)
56 {
57 try
58 {
59 Item it = FW.F.get(itemNum);
60 Gauge g = (Gauge)it;
61 return g.getValue();
62 }
63 catch(Exception e)
64 {
65 return -1;
66 }
67 }
69 /* set value to gauge */
70 public static void Lja(int itemNum, int value)
71 {
72 try
73 {
74 Item it = FW.F.get(itemNum);
75 Gauge g = (Gauge)it;
76 g.setValue(value);
77 }
78 catch(Exception e)
79 {
80 return;
81 }
82 }
84 /* get text from textfield */
85 public static String ja(int itemNum)
86 {
87 try
88 {
89 Item it = FW.F.get(itemNum);
90 TextField tf = (TextField)it;
91 return tf.getString();
92 }
93 catch(Exception e)
94 {
95 return "";
96 }
97 }
99 /* set text of field */
100 public static void ja(int itemNum, String text)
102 try
104 Item it = FW.F.get(itemNum);
105 TextField tf = (TextField)it;
106 tf.setString(text);
108 catch(Exception e)
110 return;
114 /* choice group append item (string, null) */
115 public static int I(int itemNum, String text)
117 try
119 ChoiceGroup cg = (ChoiceGroup)FW.F.get(itemNum);
120 return cg.append(text, null);
122 catch(Exception e)
124 return -1;
128 /* choice group append item (string, image) */
129 public static int I(int itemNum, String text, Image image)
131 try
133 ChoiceGroup cg = (ChoiceGroup)FW.F.get(itemNum);
134 return cg.append(text, image);
136 catch(Exception e)
138 return -1;
142 /* choice is selected item */
143 public static int L(int itemNum, int entryNum)
145 try
147 ChoiceGroup cg = (ChoiceGroup)FW.F.get(itemNum);
148 if (cg.isSelected(entryNum))
149 return -1;
150 else
151 return 0;
153 catch(Exception e)
155 return -1;
159 /* choice get selected item */
160 public static int L(int itemNum)
162 try
164 ChoiceGroup cg = (ChoiceGroup)FW.F.get(itemNum);
165 return cg.getSelectedIndex();
167 catch(Exception e)
169 return -1;
173 /* formAddDateField */
174 public static int dd(String title, int type)
176 try
178 DateField df = new DateField(title, type);
179 return FW.F.append(df);
181 catch (Exception e)
183 return -1;
187 /* formSetDate */
188 public static void dd(int index, int time)
190 try
192 DateField df = (DateField)FW.F.get(index);
193 df.setDate(new java.util.Date(((long)time) * 1000));
195 catch (Exception e)
197 return;
201 /* formGetDate*/
202 public static int dd(int index)
204 try
206 DateField df = (DateField)FW.F.get(index);
207 return (int) (df.getDate().getTime() / 1000);
209 catch (Exception e)
211 return -1;
215 /* getFormTitle*/
216 public static String gft()
218 try
220 String title = FW.F.getTitle();
221 if (title == null)
222 title = "";
223 return title;
225 catch (Exception e)
227 return "";
230 };