Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Highlighted
New Contributor
Posts: 2
Registered: ‎04-13-2010
My Device: Storm 9530
My Carrier: Bell Mobility
Accepted Solution

TouchEvent exception on vary basic app (9550 sim)

I recently got interested in programming again and decided to start out with blackberry programming. I am getting some errors right off the bat which is not encouraging but I was hoping someone could help me out.

 

I created a basic app based on the "Getting Started" first app tutorial. I added then added a button and a field listener for that button which displays a dialog alert. Very simple, but in my simulator (9550) I am getting a runtime exception that stops at 'TouchEventInternal.getGlobalX(int)'. This happens after I click 'OK' on the dialog alert.

 

Here is the Stack Trace:

Thread [Checklist(176)id=295857152] (Suspended (exception RuntimeException))	
	TouchEventInternal.getGlobalX(int) line: 222	
	ChecklistScreen(Screen).dispatchTouchEvent(TouchEvent) line: 1010	
	UiEngineImpl.processMessage(Object, Message, boolean) line: 3388	
	Checklist(Application).doProcessNextMessage(Message) line: 2268	
	Checklist(Application).processNextMessage(Message) line: 1530	
	Checklist(Application).enterEventDispatcher() line: 1371	
	Checklist.main(String[]) line: 11	

 

And Here is my Code:

 

CheckList.java:

package com.rim.samples.checklist;

import net.rim.device.api.ui.UiApplication;

public class Checklist extends UiApplication
{

	public static void main(String[] args)
	{
		Checklist theApp = new Checklist();
		theApp.enterEventDispatcher();
	}
	public Checklist()
	{
		pushScreen(new ChecklistScreen());
	}
}

 

ChecklistScreen.java:

package com.rim.samples.checklist;

import java.util.*;
import net.rim.device.api.ui.*;
import net.rim.device.api.ui.container.MainScreen;
import net.rim.device.api.ui.component.*;

public final class ChecklistScreen extends MainScreen
{
	public ChecklistScreen()
	{
		super();
		ButtonField button = new ButtonField("Add New");
		FieldChangeListener action = new FieldChangeListener(){
			public void fieldChanged(Field field, int context)
			{
				Dialog.alert("YOU PUSHED A BUTTON");
			}
		};
		button.setChangeListener(action);
		add(button);
	}
	public boolean onClose()
	{
		Dialog.alert("Cya!");
		System.exit(0);
		return true;
	}
}

 

Any help or guidance would be appreciated

 

 

 

Developer
Posts: 78
Registered: ‎12-03-2009
My Device: Not Specified

Re: TouchEvent exception on vary basic app (9550 sim)

[ Edited ]

Hey Micah_H!

 

I guess that you need access to the UI event-handling, since it seems that you are outside. So, you can use the invokeLater( ) or invokeAndWait( ) methods.

 

 

UiApplication.getUiApplication().invokeLater(new Runnable(){
	public void run() {
		Dialog.alert("YOU PUSHED A BUTTON");
	}
});

 

The other alternative is to set the CONSUME_CLICK feature at your button:

 

 

ButtonField button = new ButtonField("Add New", ButtonField.CONSUME_CLICK);

 

 

 

Anyway, honestly, I got surprised when your code works on previous simulator 9530. I do not know why!

Regards,

Klerisson

 

--
Feel free to press the kudos button on the left side to thank the user that helped you.
Please mark posts as solved if you found a solution.
New Contributor
Posts: 2
Registered: ‎04-13-2010
My Device: Storm 9530
My Carrier: Bell Mobility

Re: TouchEvent exception on vary basic app (9550 sim)

Adding CONSUME_CLICK to my button caused the error to go away. Hopefully there are no side effects to using this flag.

 

Thank you.