Hi All,
I am facing a very strange problem. I am trying to make a horizontal tab at the top of the screen. When i run the program at simulator 8300. i get the following error
JVM Error Uncaught: Runtime Exception
Scroll for available commands.
Continue
After scrolling i get the following change in the above green text "Reset" and after that "Attach Debugger". Clicking the button on "Attach Debugger" case. I used to get as follows screen
Debugger Attach Failed
Scroll for available commands
Continue
When i click in continue case i get the program i made.
Please let me know what is going on. I am not able to point the problem in program.
What may be the possible reason for this behavior.
Below is the Screen code i am using.
Code:
import net.rim.device.api.ui.Field;
import net.rim.device.api.ui.FocusChangeListener;
import net.rim.device.api.ui.component.Dialog;
import net.rim.device.api.ui.component.LabelField;
import net.rim.device.api.ui.container.HorizontalFieldManager;
import net.rim.device.api.ui.container.MainScreen;
public class LandingScreen extends MainScreen implements FocusChangeListener
{
//LabelField mostPopular = new LabelField("Most Popular",Field.FOCUSABLE|Field.FIELD_LEFT|Field.HIGHLIGHT_FOCUS);
private LabelField mostPopular;
private LabelField newlyAdded;
private LabelField allCategories;
private LabelField spacer1;
private LabelField spacer2;
public LandingScreen()
{
HorizontalFieldManager topTabManager = new HorizontalFieldManager();
mostPopular = new LabelField("Most Popular",LabelField.FOCUSABLE | LabelField.HIGHLIGHT_SELECT);
newlyAdded = new LabelField("Newly Added",LabelField.FOCUSABLE | LabelField.HIGHLIGHT_SELECT);
allCategories = new LabelField("All Categories",LabelField.FOCUSABLE | LabelField.HIGHLIGHT_SELECT);
spacer1 = new LabelField(" | ", LabelField.NON_FOCUSABLE);
spacer2 = new LabelField(" | ", LabelField.NON_FOCUSABLE);
mostPopular.setFocusListener(this);
newlyAdded.setFocusListener(this);
allCategories.setFocusListener(this);
topTabManager.add(mostPopular);
topTabManager.add(spacer1);
topTabManager.add(newlyAdded);
topTabManager.add(spacer2);
topTabManager.add(allCategories);
add(topTabManager);
}
public void focusChanged(Field field, int eventType)
{
Dialog.alert("field ="+field+" eventType="+eventType);
/*if(eventType == FOCUS_GAINED)
{
if(field == mostPopular)
{
Dialog.alert("mostPopular!");
}
if(field == newlyAdded)
{
Dialog.alert("newlyAdded!");
}
if(field == allCategories)
{
Dialog.alert("allCategories!");
}
}*/
//Dialog.alert("mostPopular!");
}
public boolean onClose()
{
Dialog.alert("Goodbye!");
//NewScreen pScreen = new NewScreen();
//UiApplication.getUiApplication().pushScreen(pScreen);
System.exit(0);
return true;
}
} Code calling the Screen
Code:
import net.rim.device.api.ui.UiApplication;
import net.rim.device.api.ui.component.Dialog;
import net.rim.device.api.ui.component.LabelField;
import net.rim.device.api.ui.component.RichTextField;
import net.rim.device.api.ui.container.MainScreen;
public class HelloWorld extends UiApplication
{
public static void main(String[] args)
{
try
{
HelloWorld hello = new HelloWorld();
hello.enterEventDispatcher();
}
catch (Exception e)
{
System.out.println("Message from main "+e.getMessage());
}
}
public HelloWorld()
{
try{
//display a new screen
pushScreen(new LandingScreen());
}
catch (Exception e)
{
System.out.println(e.getMessage());
}
}
}