2016-11-11 21 views
2

フォーム持つタブバックaddEventとaddMeeting形で - codenameone

Tabs tabs = new Tabs(Component.BOTTOM); 
tabs.addTab("Events", wrapContainerSingleTable); 
tabs.addTab("Business Meetings", wrapContainerSingleTableMeeting); 

Button addEventButton = new Button("Add Event "); 
FontImage.setMaterialIcon(addEventButton, FontImage.MATERIAL_ADD); 
wrapContainerSingleTable.add(FlowLayout.encloseRight(addEventButton)); 

addEventButton.addActionListener((e) -> { 
    showForm("AddEvent", null); 
}); 

Button addMeetingButton = new Button("Add Meeting "); 
FontImage.setMaterialIcon(addMeetingButton, FontImage.MATERIAL_ADD); 
wrapContainerSingleTableMeeting.add(FlowLayout.encloseRight(addMeetingButton)); 

addMeetingButton.addActionListener((e) -> { 
    showForm("AddMeeting", null); 
}); 

Command back = new Command("Back", backBtn) { 
    @Override 
    public void actionPerformed(ActionEvent evt) { 
     showForm("MeetingsAndEvents", this); 
    } 

}; 
back.putClientProperty("uiid", "RoundTableBack"); 
f.setBackCommand(back); 
t.addCommandToLeftBar(back); 

私はここに必要なのである私は、addイベントから戻ったときにイベントタブに移動し、同様に会議の追加タブから戻ると、会議タブに移動する必要があります。どうやってやるの?

答えて

0

actionPerformed()メソッドのタブコンポーネントでsetSelectedIndex()を使用してみてください。

0

あなたのステートマシンにこれを追加します。

protected void storeComponentState(Component c, Hashtable destination) { 
    super.storeComponentState(c, destination); 
    if(c instanceof Tabs) { 
     destination.put("TabSel" + c.getName(), ((Tabs)c).getSelectedIndex()); 
    } 
} 

protected void restoreComponentState(Component c, Hashtable destination) { 
    super.restoreComponentState(c, destination); 
    if(c instanceof Tabs) { 
     Integer i = (Integer)destination.get("TabSel" + c.getName()); 
     if(i != null) { 
      ((Tabs)c).setSelectedIndex(i.intValue()); 
     } 
    } 
} 
関連する問題