0
前言:Java ME的,LWUIT,限制存儲器(< 4MB,即使一個集裝箱/ BoxLayout的超過存儲器限制)的Java ME:ActionEvent的像超出範圍/多種形式不能很好地設置
給定:一個以上的形式,每種形式含有獨特的動作(由按鈕和/或命令)
任務:如何確定從顯示形式操作(例如:(currentForm == formX))
問題:一個不存在源(在給定的,當前的形式)正在經過像真的
public class expMIDlet extends MIDlet implements ActionListener {
...
Form expTimerForm;
Form presetForm;
Form slimForm;
...
public void actionPerformed(ActionEvent ae) {
...
if (ae.getSource() == calcButton) {
...
}
if (ae.getCommand() == command2) {
...
// this will be EVEN executed in a Form that do not contain command2
// if there was some event in that Form
}
...
}
...
}
這是我在這一點骯髒的解決方案:
- 順序由用戶流事件和使用if/else結構
- 使用「if或switch /箱(badIdea == X) 「並確定以何種方式形成我是(通過設置‘badIdea = currentID’如果有的話的形式被改變)
.getSource(),然後.getParent() - 謝謝! –