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
New Contributor
tus0169
Posts: 9
Registered: ‎02-26-2010
My Device: 8300
My Carrier: Orange
Accepted Solution

NullPointerException on new screen

Hi,

 

I have created a custom menu item to launch a new screen. When I try it on the simulator, I get a null pointer exception.

 

The run method of the menu item:

 

 

public Object run(Object context) {
   UiApplication.getUiApplication().pushScreen(new ExtendedMenuGUI());
   return context;
}

 

 

The screen class

 

 

public class ExtendedMenuGUI extends MainScreen {
	
	private MainScreen mainScreen;
	private static RichTextField commentZone;
	
	
	public ExtendedMenuGUI() {
		// Initialize the fields.
		commentZone = new RichTextField("Entrez vos commentaires ici", RichTextField.NON_FOCUSABLE);
		LabelField title = new LabelField("Validation", LabelField.ELLIPSIS | LabelField.USE_ALL_WIDTH);
		mainScreen.setTitle(title);
		mainScreen.add(commentZone);
	}
}

 

Does anyone knows where the problem comes from ?

 

Thanks a lot for your help.

 

T

 

Please use plain text.
Developer
dpreussler
Posts: 212
Registered: ‎07-18-2008
My Device: Storm 9550

Re: NullPointerException on new screen

[ Edited ]

you never assigned anything to your

mainScreen

variable

 

probably you don't need it at all. simple use "this" because your class extends MainScreen

 

	this.setTitle(title);
this.add(commentZone);
If your problem was solved, please mark answer as "Accepted solution"
If your want to thank, click the "kudo" symbol
___________
visit me: http://mobilejavadevelopment.blogspot.com/
visit the Berlin BlackBerry Developer Group: http://berlinblackberrydevelopers.blogspot.com/
Please use plain text.