Note that there are some explanatory texts on larger screens.

plurals
  1. POdynamic button creation to the form using lwuit 1.4
    text
    copied!<pre><code>public class StateMachine extends StateMachineBase { public Container con1; protected void beforeMainForm(Form f) { con1 = findMenucon(f);&lt;Br&gt; super.beforeMainForm(f);&lt;br&gt; } } //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("-------&gt;&gt;&gt;"); bname=new Vector(); this.readmenu(); b = new Button[bname.size()]; System.out.println(b.length+bname.toString()); for (int i = 0; i&lt;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."); } </code></pre> <p>I am using the above code for creation dynamic <code>Button</code> using json. i can get the value in console but could not get the <code>Button</code> in the <code>Form</code></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload