View Single Post
Old 05-15-2010, 10:45 PM   #15 (permalink)
BlackBerry Extraordinaire
Join Date: Mar 2008
Location: Austin, TX
Model: 9700
Carrier: T-Mobile
Posts: 1,644
Post Thanks: 0
Thanked 34 Times in 33 Posts

...and here is another issue:

The code the calculates the GPA is in the constructor of the SemGPAScreen class. This is never going to work. You need to understand that this is EVENT DRIVEN programming, not linear/procedural programming.

You are adding some fields to the screen in the constructor (correct), then attempting to retrieve the values from the fields in the same constuctor (incorrect). The fields will not even be displayed to the user until you exit the constructor and allow the framework to display the screen.

What you need to do here is probably have a button on this screen "Submit" (or something like that). You place a listener on the button, then perform the calculations and display the results in another screen (or in a text field that you add to this screen).

What is happening with your code is that the calcs are performed on null values (yielding no useful data), then you try to put up a dialog (which will fail with an IllegalState exception, since you have not even entered the event thread when this Dialog is called).

Going back to my original advice: get yourself a book (there are several beginner BB Java books available now), and work through the examples. There is nothing in what you are attempting that is very complicated - your difficulties lie in the fact that you do not understand the basic principles.
Offline   Reply With Quote