public class StateMachine extends StateMachineBase {
public Container con1;
protected void beforeMainForm(Form f) {
con1 = findMenucon(f);<Br>
super.beforeMainForm(f);<br>
}
}
//class mainmidlet()
public void run() {
try {
//new StateMachine("/App.res");
new mainform("/App.res");
} catch (Exception ex) {
ex.printStackTrace();
}
}
class mainform implements ActionListener{
Vector bname;
Button[] b;
String mainmenu=null;
Form frm;
mainform(String string) {
try {
Resources res = Resources.open(string);
UIManager.getInstance().setThemeProps(res.getTheme(res.getThemeResourceNames()[0]));
UIBuilder builder = new UIBuilder();
frm = (Form)builder.createContainer(res, "MainForm");
StateMachine sm=new StateMachine("/App.res");
System.out.println("------->>>");
bname=new Vector();
this.readmenu();
b = new Button[bname.size()];
System.out.println(b.length+bname.toString());
for (int i = 0; i<b.length; i++) {
b[i] = new Button(bname.elementAt(i).toString());
b[i].setAlignment(Label.CENTER);
b[i].getStyle().setMargin(2,5,5,5);
b[i].getStyle().setPadding(5,5,5,5);
System.out.println(b[i].toString());
b[i].addActionListener(this);
sm.con1.addComponent(b[i]);
//System.out.println("\n " + b[i]);
}
frm.addComponent(sm.con1);
frm.show();
}
catch(IOException err) {
err.printStackTrace();
}
public void actionPerformed(ActionEvent ae) {
throw new UnsupportedOperationException("Not supported yet.");
}
Button
上記のコードを使用して、 jsonを使用して動的に作成しています。コンソールで値を取得できましたが、で値を取得できませんでしButton
たForm