2011-07-27 3 views
1
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."); 
} 

json을 사용하여 동적 작성 용 Button 위의 코드를 사용하고 있습니다. 콘솔에서 값을 얻을 수 있지만 Button을 가져올 수 없습니다. Formlwuit 1.4를 사용하여 양식에 동적 단추 만들기

+0

에 재 검증을() 수행도 공연 후 양식에 추가 할 수 있습니다한다고 생각합니다 bname'? – bharath

+0

readmenu() {bname.addElement (jarray.get (i));}; 나는 콘솔의 버튼 값을 얻을 수 있지만 .... 형태로 생성되지 않은 버튼은 – raja

답변

1

기본 클래스가 폼을 만들고 표시하기 때문에 상태 시스템이 1.4 BTW의 일부가 아닙니다. 자체 테마를 설정하고 이전에 수행 한 작업을 무시합니다.

con1의 생성/정의를 무시하고 장치에서 실행되지 않는 UnsupportedOperationException에 대한 호출을 포함했습니다.

모든 LWUIT 코드는 상태 시스템에 있어야합니다. T-zone 데모를 포함하여 데모를 따라 가면됩니다. 여기서 우리는 애니메이션을 만들 때 제목을 바꿉니다. 이 모든 코드는 전적으로 상태 머신에 있으며 특정 폼 초기화 메소드를 덮어 쓰고 거기에서 폼을 수정합니다.

수동으로 모든 것을 쓰고 싶다면 상태 머신을 사용하지 말고 직접 UIBuilder를 사용하십시오.

+0

Shai Almog ..... – raja

0

나는 당신이 당신의 버튼을 건설 한 후, 당신은 아직도 당신이`에`JSON` 값을 추가 어디 양식

frm.revalidate(); 
+0

감사합니다. ...베드로........ – raja