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
Developer
Developer
TEP
Posts: 42
Registered: ‎02-17-2009
My Device: Not Specified
Accepted Solution

MenuItem / JDE 4.5

I have created an application for JDE 4.7 and have successfully added menus using the following code:

 

private class AboutScreen extends MainScreen { public AboutScreen() { super(); setTitle(" About"); LabelField about = new LabelField(); about.setText("Some text"); add(about); } } private MenuItem _aboutItem = new MenuItem("About", 110, 100) { public void run() { _aboutScreen = new AboutScreen(); UiApplication.getUiApplication().pushScreen(_aboutScreen); } }; private class HelpScreen extends MainScreen { public HelpScreen() { super(); setTitle(" Help"); LabelField about = new LabelField(); about.setText("Some text"); add(about); } } private MenuItem _helpItem = new MenuItem("Help", 120, 100) { public void run() { _helpScreen = new HelpScreen(); UiApplication.getUiApplication().pushScreen(_helpScreen); } }; //create a menu item for users to close the application private MenuItem _closeItem = new MenuItem("Close", 200000, 10) { public void run() { onClose(); } }; //override makeMenu to add the new menu items protected void makeMenu( Menu menu, int instance ) { menu.add(_aboutItem); menu.add(_closeItem); menu.add(_helpItem); }

 

When I compiled the same application using JDE 4.5, the application compiles without any issues. The application runs as well. However, when I select the menus I am adding (about or help), I get a "JVM Error 104 Uncaught:IllegalStateException". Once I click continue, the menu screen appears however the labelField does not.

 

Can someone point me in the proper direction? I am a new developer still learning the ropes. I did look through the forums but have not found anything the proved to be helpful in my particular situation. I appreciate any and all input that helps me learn what I am doing wrong.

Developer
mantaker
Posts: 1,477
Registered: ‎12-30-2008
My Device: Torch 9810

Re: MenuItem / JDE 4.5

JVM 104 error will not appear on real device! Did you check it in the device?

 

Cheers.. 

--
Manimaran Selvan
Co-Founder, Tech Lead,
Equity Markets Research Group
Developer
Developer
TEP
Posts: 42
Registered: ‎02-17-2009
My Device: Not Specified

Re: MenuItem / JDE 4.5

Yes, I tried it on a 8703e. The application runs just fine. When you click in the track wheel, the only menu item that appears is the "close". The two items I am trying to add do not appear. I apologize for not including this previously.
Developer
peter_strange
Posts: 19,610
Registered: ‎07-14-2008
My Device: Not Specified

Re: MenuItem / JDE 4.5

Can you please confirm that you are reporting two problems and if so, when you see them:

 

1) When you see the Help and About, pressing on them gives you a 104 error

Do see this on the Simulator or the device?  What JDE is involved.  If on a device, what device and what OS is involved.  If a Sim, what Sim and level of OS.

 

2) When you try this on an 8703, you do not see your extra menu items

What level of OS is running on the device?

 

My immediate thought about the problems would be to confirm that you are running this software on devices or simulators that have pre 4.5 levels of OS installed.

Developer
Developer
TEP
Posts: 42
Registered: ‎02-17-2009
My Device: Not Specified

Re: MenuItem / JDE 4.5

1) The 104 error occurs when using the simulator. I am using Eclipse with the JDE Plugins. The Plugin version I am using to compile and test with in Eclipse is 4.5.0.16. When I run the Simulator, the OS version is reporting 4.5.0.44 and the simulator is the default one that runs for the 4.5 plugin (8300 series). On the simulator, I see the menus. When I select one, I get a 104 error, I click continue, the screen then shows up with nothing on the screen other than the title.

 

2) On the 8703, I am not seeing the extra menus at all. I only see the default "close" and "check spelling". The application runs normally with the exception of not seeing the menus. The 8703 is running OS 4.5.0.148.

 

When compiling this application for earlier OS levels I went to 4.5. I have made sure to only use devices or simulators running 4.5 software. I had originally thought the way I created the menus was not compatible with 4.5 software but after looking at the API documentation nothing is jumping out at me as to the cause of the problem. I do appreciate the help. I am learning more and more from it.

 

 

Developer
peter_strange
Posts: 19,610
Registered: ‎07-14-2008
My Device: Not Specified

Re: MenuItem / JDE 4.5

1.  Just tried this in 4.5 JDE running the standard SImulator, works fine.

 

2.  Sorry don't have an 8703 to test on

 

What are you adding this to.  I used a MainScreen.

Developer
Developer
TEP
Posts: 42
Registered: ‎02-17-2009
My Device: Not Specified

Re: MenuItem / JDE 4.5

[ Edited ]

Yes, I am adding this to the MainScreen. I think I figured out the problem with the menu items. I have been using a labelField with setText and formatting the text using "\n" or "\t". I have also been breaking the line up between the quotes ("") using a plus (+) sign so that it doesn't scroll off the screen. I have commented all of that out and put just one word into the labelField to see if that would change anything. It runs in the simulator just fine now. The 8703 doesn't have a BB menu button so I am not sure what I was really thinking there. I guess I was just trying to use a physical device that is running 4.5.

 

I will go and look to see if there is a limit to what can be placed in a labelField under JDE 4.5. I do not experience this issue with the any of the other JDE compilers (4.6, 4.6.1, or 4.7). It is only with 4.5. Thanks for your time.

Message Edited by TEP on 05-27-2009 10:49 AM
Developer
mantaker
Posts: 1,477
Registered: ‎12-30-2008
My Device: Torch 9810

Re: MenuItem / JDE 4.5

What I had seen was a LabelField never accepted a new line, rather it goes to the next line when its content exceeds the first line limit.. However when you use a \n, the characters that comes after it will not be visible..

 

Cheers.. 

--
Manimaran Selvan
Co-Founder, Tech Lead,
Equity Markets Research Group
Developer
Developer
TEP
Posts: 42
Registered: ‎02-17-2009
My Device: Not Specified

Re: MenuItem / JDE 4.5

I am not sure what I was thinking when I started filling out a labelField with text and then formatting it. I should have used a RichTextField from the start. I changed the labelField to RichTextFields in my two menu items and all is well. No more JVM 104 errors.

 

When I said I am new to developing applications, I really meant that I am new to developing applications. I am finding that what I learned in my college classes only takes you so far. You have to get your nose to the grindstone and write some applications to get the experience necessary to know what works and what doesn't work.

 

Anyway, I appreciate your input along with the input I received from Peter.