10-07-2008 12:44 AM
I have an application(J2ME Polish) that is running fine on Nokia,Samsung and other mobile. But when I run it on Blackberry using JDE 4.2 it hangs. The environment I am using is:- Netbeans 6.0 with Mobility pack, J2ME polish framework , JDE 4.2 version.
When I run the Jdp (created in the dist folder using IDE Netbeans and Blackberry 4.2 with trackball configuration) in JDE 4.2 it shows me the error "IllegalArgumentException. Could not paint the screen"
I want to know how can I customize my existing J2mE smart client application for BlackBerry with least efforts. I have checked Polish Documentation available on internet for blackberry also but I don't find it complete. As per that Polish Documenttion I have made my Midlet constructor public.
I am stuck now and need urgent help.
10-07-2008 02:28 PM
10-08-2008 08:39 AM
My Midlet class is:
public class OctillaMIDlet extends MIDlet implements CommandListener {
static String[] msgTab;
public Session session;
private static int selectedTrip;
// Interface irrespective of their Screen type
// Flight , Car, Hotel etc.
ICommandProcessor cmdProcessor;
SplashForm splashForm;
GaugeForm gaugeForm;
EventsMenuForm eventScreen = null;
BookingMenuForm bookingScreen = null;
Display display;
Alert alertScreen;
public Displayable nextScreen, previousScreen;
public static Command cmdSelect, cmdExit, cmdNext, cmdEditProfile, cmdFindFlight;
public OctillaMIDlet (){
}
public void startApp() {
session = new Session(this);
display = Display.getDisplay(this);
// Reading property file for Internationalization/Localization.
initMsg();
cmdExit = new Command(getMsg(MessageConstants.EXIT), Command.CANCEL, 10);
cmdNext = new Command(getMsg(MessageConstants.NEXT), Command.SCREEN, 5);
cmdSelect = new Command(getMsg(MessageConstants.SELECT), Command.OK, 10);
cmdEditProfile = new Command(getMsg(MessageConstants.EDIT_PROFILE), Command.SCREEN, 6);
cmdFindFlight = new Command(getMsg(MessageConstants.FIND_FLIGHT), Command.SCREEN, 5);
splashForm = new SplashForm("", this, display);
splashForm.addCommand(cmdExit);
splashForm.addCommand(cmdSelect);
splashForm.setCommandListener(this);
gaugeForm = new GaugeForm("", false);
display.setCurrent(splashForm);
}
public void pauseApp() {
}
public void destroyApp(boolean bol) {
}
private List getBookingOptionForm() {
bookingScreen = new BookingMenuForm();
bookingScreen.addCommand(cmdExit);
bookingScreen.setCommandListener(this);
return bookingScreen;
}
public void commandAction(Command cmdType, Displayable currentScreen) {
if (currentScreen == splashForm) {
if (cmdType == cmdSelect) {
session.message = MessageConstants.DISPLAY_EVENTS;
this.nextScreen = getEventOptionForm();
this.previousScreen = splashForm;
startLoading(true, getMsg(MessageConstants.LOADING_EVENTS));
}
else if (cmdType == cmdExit) {
notifyDestroyed();
}
}
else if (currentScreen == eventScreen) {
if (cmdType == List.SELECT_COMMAND) {
// get selected Index from Event Selecting Form
int index = this.eventScreen.getSelectedIndex();
// If the selected index is Travel
switch (index) {
case 0: // MessageConstants.EVENT_MAKE_A_CALL :
showAlert(getMsg(MessageConstants.EVENT_MAKE_A_CAL
break;
case 1: //MessageConstants.EVENT_MONEY_TRANSFER :
showAlert(getMsg(MessageConstants.EVENT_MONEY_TRAN
break;
case 2: //MessageConstants.EVENT_TRAVEL :
session.message = MessageConstants.DISPLAY_EVENTS;
this.previousScreen = this.nextScreen;
this.nextScreen = getBookingOptionForm();
startLoading(true, getMsg(MessageConstants.LOADING_BOOKINGS));
break;
}
}
else if (cmdType == cmdExit) {
notifyDestroyed();
}
}
else if (currentScreen == bookingScreen) {
if (cmdType == List.SELECT_COMMAND) {
selectedTrip = this.bookingScreen.getSelectedIndex();
System.out.println("bookingScreen Index Value:: " + selectedTrip);
switch (selectedTrip) {
case 0: // MessageConstants.BOOK_AIR :
cmdProcessor = (ICommandProcessor) (FlightCommandProcessor.getInstance());
((FlightCommandProcessor) cmdProcessor).tripModeScreen = null;
session.message = MessageConstants.DISPLAY_EVENTS;
this.previousScreen = this.nextScreen;
this.nextScreen = ((FlightCommandProcessor) cmdProcessor).getTripSelectForm(this);
startLoading(true, getMsg(MessageConstants.LOADING_TRIPMODES));
break;
case 1: //MessageConstants.BOOK_HOTEL :
showAlert(getMsg(MessageConstants.BOOK_HOTEL));
break;
case 2: //MessageConstants.BOOK_CAR :
showAlert(getMsg(MessageConstants.BOOK_CAR));
break;
}
}
else if (cmdType == cmdExit) {
this.nextScreen = this.previousScreen;
startLoading(true, getMsg(MessageConstants.LOADING_BOOKINGS));
}
}
else {
cmdProcessor.processCommand(this, cmdType, currentScreen);
}
}
My Form class is:
SplashForm
public class SplashForm extends Form {
private MIDlet bookMidlet;
private Display currentDisplay;
public SplashForm(String title, MIDlet objMidlet,Display objDisplay)
{
//#style splashBackground
super(" " ) ;
this.bookMidlet = objMidlet;
this.currentDisplay = objDisplay;
//#style ticker
this.setTicker("Applicaton Ticker Text" ) ;
}
}
BookingMenuForm
package com.slc.screens;
import com.slc.OctillaMIDlet;
import com.slc.common.MessageConstants;
import javax.microedition.lcdui.List;
import javax.microedition.lcdui.Ticker;
public class BookingMenuForm extends List {
public BookingMenuForm() {
//#style otherBackground
super("", List.IMPLICIT);
//#style bookItemAir
this.append("Air", null);
//#style bookItemHotel
this.append("Hotel"null);
//#style bookItemCar
this.append("Car"null);
//#style ticker
this.setTicker(new Ticker("Application Ticker Text" ) ) ;
}
}
Polish CSS used is:
.splashBackground {
padding-left: 15;
padding-right: 15;
background-image: url('splashImage.jpg');
background-color : backgrndColor;
background-anchor: vertical-center | horizontal-center;
layout: horizontal-expand | horizontal-center | top; padding-top:5; padding-bottom:5
}
.otherBackground {
padding-left: 5;
padding-right: 5;
background-color : backgrndColor;
layout: left;
max-height: 12;
font-size: small;
font-style: bold ;
}
.Items
{
margin: 2; /* for the border of the :hover style */
padding: 5;
background-color : backgrndColor;
background-anchor: vertical-center | horizontal-center;
layout: expand | center;
}
.bookItem extends Items {
font-color: menuItemFontColor;
font-style: bold;
max-width: 150;
}
.bookItem:hover {
margin: 0;
background {
type: round-rect;
arc: 8;
color: itemHoverBgColor;
border-color: itemFontColor;
border-width: 1;
}
layout: expand | center;
}
.bookItemAir extends bookItem
{
font-size: medium;
icon-image: url( bookingIconLeft0.jpg );
icon-image-align: left;
}
.bookItemCar extends bookItem
{
font-size: medium;
icon-image: url( bookingIconLeft1.jpg );
icon-image-align: left;
}
.bookItemHotel extends bookItem
{
font-size: medium;
icon-image: url( bookingIconRight.jpg );
icon-image-align: right;
}
.ticker {
font-color: white;
font-style: bold;
font-size: small;
font-face: proportional;
background-color: red;
}
When I load the .cod file generated from Netbeans IDE I could see the Exception in JDE console
Could not paint the SplashScreenForm,IllegalArgument Exception some 8- 10 times
Could not paint the EventOptionForm, Illegal ArgumentException some 8-10 times
I am not getting the exact linenumber.
Is there any set guidelines to port the application ,designed using j2me polish framework, on Blackberry?
If not, please suggest what is the safest approach to follow ,otherwise, I will end up making a new application for each model using native API. My objective is to port this application on around 250 models.
Thanks
01-11-2012 02:29 AM
Even I am trying to use existing j2me code but when I try it with BlackBerry jde plugin it doesnt support j2me polish
My app runs successfully in simulator but it doesn't use my polish.css file and also TableItem widget is invisible.
01-11-2012 09:31 AM
I guess its similar to the below mentioned thread
http://supportforums.blackberry.com/t5/Java-Develo
-Abhijit B