Skip to main content

cal.showPacked(BorderLayout.CENTER, true); <- This line will hang the Blackberry (but not J2ME mobiles) any idea?

4 replies [Last post]
68060
Offline
Joined: 2011-08-29
Points: 0

Well i think the subject says it all:

cal.showPacked(BorderLayout.CENTER, true); <- This line will hang the Blackberry (but not J2ME mobiles) any idea?

Shame because the date selector ive made works real nice on j2me, but when I pop it up on blackberry the device hangs, tried on 9500 and 8800.. both hang.

MY METHOD:

public void showCalendar(final TextField tf)
{
_("showCalendar");
final Dialog cal = new Dialog();
_("a");//for bb diagnosis why crashes on calendar
final com.sun.lwuit.Calendar c = new com.sun.lwuit.Calendar();
c.setFocus(true);
c.addActionListener(this);
_("b");//for bb diagnosis why crashes on calendar
cal.addComponent(c);

cal.addCommand(new Command("Cancel") {

public void actionPerformed(ActionEvent evt) {
cal.dispose();
}
});
_("c");//for bb diagnosis why crashes on calendar
cal.addCommand(new Command("Done") {

public void actionPerformed(ActionEvent evt) {
_("done..");
recentlySelectedDate = getDateString( c.getDate() );
tf.setText(recentlySelectedDate);
}
});
_("d");//for bb diagnosis why crashes on calendar
c.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
_("Selected date :: " + c.getDate().toString());

}
});
_("e");//for bb diagnosis why crashes on calendar
// dialog.show(0,0,0,0, true, false);

//THIS LINE CRASHES BLACKBERRY!
cal.showPacked(BorderLayout.CENTER, true);//showPacked gives it more space or allows it to grow apparently ?
_("f");

_("dimension is "+frm.getWidth()+" X "+frm.getHeight());
Dimension d = new Dimension( frm.getWidth(),frm.getHeight());
cal.setSize( d );
_("showCalendar done");

}

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
vprise
Offline
Joined: 2003-11-07
Points: 0

RIM is very sensitive to threading issues, make sure that showCalendar() is invoked on the EDT.

68060
Offline
Joined: 2011-08-29
Points: 0

hi - im not 100% sure what this means? any quick example, or do I just fire off another thread to show calendar??

tempusername
Offline
Joined: 2009-03-25
Points: 0

what vprise means is you should call your method (or at least the parts of it that calls to the lwuit ui) from the EDT

to check if your already on the EDT thread use Display.getInstance().isEdt()

to run code on the EDT thread use

Display.getInstance().callSerially(
new Runnable() {
//your code here
});

Technically if im not mistaken all ui related calls *should* be done on the EDT however lwuit works even if some of the calls not done on the EDT but can lead to mixed results like your BB case.

vprise
Offline
Joined: 2003-11-07
Points: 0

Yep.

LWUIT doesn't check for illegal calls (off the EDT) both to allow hackers to do things the "know are right" e.g. the HTMLComponent violates the EDT on purpose for performance). And for the reason of performance (EDT validity checks are expensive).

RIM (and many other vendors) have their own EDT thread which is separate from LWUIT. But unlike other vendors they actually fail if you do anything off the EDT or without their EDT lock (don't ask...) .