Results 1 to 3 of 3
- 04-25-2011, 02:48 PM #1
Member
- Join Date
- Oct 2009
- Location
- Victoria, Australia
- Posts
- 4
- Rep Power
- 0
Events in commandAction(command, item) in MIDlet
Hi,
I'm having an issue with a Java MIDlet which I am editing in Netbeans 6.9.1.
The commandAction(command,item) is a Netbeans auto-generated method.
With the code below, if the strDeleteData text is clicked during runtime then it displays an alert with two options - Yes and No. This works fine, but I'm stuck on the next part.
The event triggered when either the Yes and No buttons are clicked is getting lost at the top of the commandAction(..,..) method. When either the Yes and No button is clicked, the event is triggered, but when it hits the commandAction method, it doesn't match strDeleteData or any of the other action commands, so the code for this will not be executed.
I'm stuck on this issue, and as Netbeans is being a pain with guarded line blocks it's making it rather tough.
So if you could please take a look and let me know if you have any ideas how I can proceed with this, that would be just super!
Java Code:public void commandAction(Command command, Item item) { // write pre-action user code here if (item == strDeleteData) { if (command == itemCommand) { // write pre-action user code here Alert deleteAlert1 = new Alert("Warning", "Are you sure you want to delete all saved data?", null, AlertType.WARNING); Command deleteAllYes = new Command("Yes", Command.OK, 1); Command deleteAllNo = new Command("No", Command.CANCEL, 1); deleteAlert1.setTimeout(Alert.FOREVER); deleteAlert1.addCommand(deleteAllYes); deleteAlert1.addCommand(deleteAllNo); deleteAlert1.setCommandListener(this); getDisplay().setCurrent(deleteAlert1); if(command == deleteAllYes){ //code goes here for when Yes is pressed //...... } else if(command == deleteAllNo){ //code goes here for when No is pressed //... } // write post-action user code here } } else if (item == strSaveNewSubject) { //code below for another Command event } }//end commandAction method
- 05-01-2011, 01:40 AM #2
Member
- Join Date
- Oct 2009
- Location
- Victoria, Australia
- Posts
- 4
- Rep Power
- 0
Hi again,
As I was still unable to solve this issue (and I'm guessing those who also read this weren't able to assist), I went with an alternative solution that reaches the same outcome.
Instead of having an alert displaying yes/no to confirm delete; I created a new screen which contained a bigger image, more info explaining the delete process etc and with yes/no buttons. Worked a treat.
Cheers
[Edit]
I forgot to mention, that as this issue is still not solved and the problem could reporoduce again for others; if you can please assist that would be great.
ThanksLast edited by Sasquatch192; 05-01-2011 at 01:42 AM. Reason: Thread still not solved.
- 05-01-2011, 03:43 AM #3
Similar Threads
-
typed events vs untyped events.
By Drun in forum SWT / JFaceReplies: 0Last Post: 11-23-2009, 12:22 PM -
Menu item not working properly for mouse events
By Preethi in forum New To JavaReplies: 1Last Post: 09-23-2008, 08:56 AM -
Adding command buttons on MIDLet Forms
By Java Tip in forum Java TipReplies: 0Last Post: 11-22-2007, 09:57 AM -
Unable to execute command line command in java
By LordSM in forum New To JavaReplies: 1Last Post: 08-08-2007, 12:23 AM
Bookmarks