Preface: Java ME, LWUIT, restricted memory (< 4mb, even a Container/BoxLayout exceeds memory limit)
Given: more then one form, each form contains unique actions (by buttons and/or commands)
Quest: How to determine from which form action appears (like: ?(currentForm == formX))
Problem: a not existing source (at a given, current form) is passing by like true
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
}
...
}
...
}
this are my dirty solutions at that point:
- order the events by user flow AND use an if/else construct
- use "if or switch/case (badIdea == x)" and determine that way in which form i am (by setting "badIdea = currentID" ever if the form is changed)