Search Results

Search found 23 results on 1 pages for 'lcdui'.

Page 1/1 | 1 

  • how to create class alert using lcdui package in blackberry

    - by Baby
    Advance Thanks.i am new to blackberry developement.i try the following code for creating alert using lcdui package.but nothing will coming when i am running Plz help me. package alertpack; import javax.microedition.lcdui.Alert; import javax.microedition.lcdui.AlertType; import javax.microedition.lcdui.Command; import javax.microedition.lcdui.CommandListener; import javax.microedition.lcdui.Display; import javax.microedition.lcdui.Displayable; import javax.microedition.lcdui.Form; import javax.microedition.lcdui.Screen; import javax.microedition.midlet.MIDlet; import javax.microedition.midlet.MIDletStateChangeException; import net.rim.device.api.ui.Color; import net.rim.device.api.ui.Graphics; public class alertclass extends MIDlet implements CommandListener { private Display display; private Alert alert; private Form form = new Form("Throw Exception"); private Command exit = new Command("Exit", Command.SCREEN, 1); //public static void main(String[] args) //{ //} private boolean exitFlag = false; public alertclass(){ display = Display.getDisplay(this); form.addCommand(exit); form.setCommandListener(this); } protected void destroyApp(boolean unconditional) throws MIDletStateChangeException { // TODO Auto-generated method stub if (unconditional == false) { throw new MIDletStateChangeException(); } } protected void pauseApp() { // TODO Auto-generated method stub } protected void startApp() throws MIDletStateChangeException { // TODO Auto-generated method stub display.setCurrent(form); } public void commandAction(Command c, Displayable d) { // TODO Auto-generated method stub if (c == exit) { try { if (exitFlag == false) { alert = new Alert("Busy", "Please try again.", null, AlertType.WARNING); alert.setTimeout(Alert.FOREVER); display.setCurrent(alert, form); destroyApp(false); } else { destroyApp(true); notifyDestroyed(); } } catch (Exception exception) { exitFlag = true; } } } }

    Read the article

  • How to interact between GameCanvas and LCDUI elements on J2ME?

    - by Santiago
    The thing is I writing a J2ME program that fisrt of all show a "menu" using graphics interface (GameCanvas) and when the user select one item, I need to setCurrent that item (ex. a List), but when return from the List (it could be because the user push a Command "Menu" Item) I need to show the menu again. The real problem when the menu show again, the keyPressed() listener of gamecanvas object stop working. Basically I have: A Midlet object with: GameCanvas object instance A List object instance I don't understand how that works, I didn't find tutorial that share low and high graphics-level APIs on one Midlet.

    Read the article

  • Sent Item code in java

    - by Farhan Khan
    I need urgent help, if any one can resolve my issue it will be very highly appriciated. I have create a SMS composer on jAVA netbians its on urdu language. the probelm is its not saving sent sms on Sent items.. i have tried my best to make the code but failed. Tomorrow is my last day to present the code on university please help me please below is the code that i have made till now. Please any one.... /* * To change this template, choose Tools | Templates * and open the template in the editor. */ package newSms; import javax.microedition.io.Connector; import javax.microedition.midlet.*; import javax.microedition.lcdui.*; import javax.wireless.messaging.MessageConnection; import javax.wireless.messaging.TextMessage; import org.netbeans.microedition.util.SimpleCancellableTask; /** * @author AHTISHAM */ public class composeurdu extends MIDlet implements CommandListener, ItemCommandListener, ItemStateListener { private boolean midletPaused = false; private boolean isUrdu; String numb=" "; Alert alert; //<editor-fold defaultstate="collapsed" desc=" Generated Fields ">//GEN-BEGIN:|fields|0| private Form form; private TextField number; private TextField textUrdu; private StringItem stringItem; private StringItem send; private Command exit; private Command sendMesg; private Command add; private Command urdu; private Command select; private SimpleCancellableTask task; //</editor-fold>//GEN-END:|fields|0| MessageConnection clientConn; private Display display; public composeurdu() { display = Display.getDisplay(this); } private void showMessage(){ display=Display.getDisplay(this); //numb=number.getString(); if(number.getString().length()==0 || textUrdu.getString().length()==0){ Alert alert=new Alert("error "); alert.setString(" Enter phone number"); alert.setTimeout(5000); display.setCurrent(alert); } else if(number.getString().length()>11){ Alert alert=new Alert("error "); alert.setString("invalid number"); alert.setTimeout(5000); display.setCurrent(alert); } else{ Alert alert=new Alert("error "); alert.setString("success"); alert.setTimeout(5000); display.setCurrent(alert); } } void showMessage(String message, Displayable displayable) { Alert alert = new Alert(""); alert.setTitle("Error"); alert.setString(message); alert.setType(AlertType.ERROR); alert.setTimeout(5000); display.setCurrent(alert, displayable); } //<editor-fold defaultstate="collapsed" desc=" Generated Methods ">//GEN-BEGIN:|methods|0| //</editor-fold>//GEN-END:|methods|0| //<editor-fold defaultstate="collapsed" desc=" Generated Method: initialize ">//GEN-BEGIN:|0-initialize|0|0-preInitialize /** * Initializes the application. It is called only once when the MIDlet is * started. The method is called before the * <code>startMIDlet</code> method. */ private void initialize() {//GEN-END:|0-initialize|0|0-preInitialize // write pre-initialize user code here //GEN-LINE:|0-initialize|1|0-postInitialize // write post-initialize user code here }//GEN-BEGIN:|0-initialize|2| //</editor-fold>//GEN-END:|0-initialize|2| //<editor-fold defaultstate="collapsed" desc=" Generated Method: startMIDlet ">//GEN-BEGIN:|3-startMIDlet|0|3-preAction /** * Performs an action assigned to the Mobile Device - MIDlet Started point. */ public void startMIDlet() {//GEN-END:|3-startMIDlet|0|3-preAction // write pre-action user code here switchDisplayable(null, getForm());//GEN-LINE:|3-startMIDlet|1|3-postAction // write post-action user code here form.setCommandListener(this); form.setItemStateListener(this); }//GEN-BEGIN:|3-startMIDlet|2| //</editor-fold>//GEN-END:|3-startMIDlet|2| //<editor-fold defaultstate="collapsed" desc=" Generated Method: resumeMIDlet ">//GEN-BEGIN:|4-resumeMIDlet|0|4-preAction /** * Performs an action assigned to the Mobile Device - MIDlet Resumed point. */ public void resumeMIDlet() {//GEN-END:|4-resumeMIDlet|0|4-preAction // write pre-action user code here //GEN-LINE:|4-resumeMIDlet|1|4-postAction // write post-action user code here }//GEN-BEGIN:|4-resumeMIDlet|2| //</editor-fold>//GEN-END:|4-resumeMIDlet|2| //<editor-fold defaultstate="collapsed" desc=" Generated Method: switchDisplayable ">//GEN-BEGIN:|5-switchDisplayable|0|5-preSwitch /** * Switches a current displayable in a display. The * <code>display</code> instance is taken from * <code>getDisplay</code> method. This method is used by all actions in the * design for switching displayable. * * @param alert the Alert which is temporarily set to the display; if * <code>null</code>, then * <code>nextDisplayable</code> is set immediately * @param nextDisplayable the Displayable to be set */ public void switchDisplayable(Alert alert, Displayable nextDisplayable) {//GEN-END:|5-switchDisplayable|0|5-preSwitch // write pre-switch user code here Display display = getDisplay();//GEN-BEGIN:|5-switchDisplayable|1|5-postSwitch if (alert == null) { display.setCurrent(nextDisplayable); } else { display.setCurrent(alert, nextDisplayable); }//GEN-END:|5-switchDisplayable|1|5-postSwitch // write post-switch user code here }//GEN-BEGIN:|5-switchDisplayable|2| //</editor-fold>//GEN-END:|5-switchDisplayable|2| //<editor-fold defaultstate="collapsed" desc=" Generated Method: commandAction for Displayables ">//GEN-BEGIN:|7-commandAction|0|7-preCommandAction /** * Called by a system to indicated that a command has been invoked on a * particular displayable. * * @param command the Command that was invoked * @param displayable the Displayable where the command was invoked */ public void commandAction(Command command, Displayable displayable) {//GEN-END:|7-commandAction|0|7-preCommandAction // write pre-action user code here if (displayable == form) {//GEN-BEGIN:|7-commandAction|1|16-preAction if (command == exit) {//GEN-END:|7-commandAction|1|16-preAction // write pre-action user code here exitMIDlet();//GEN-LINE:|7-commandAction|2|16-postAction // write post-action user code here } else if (command == sendMesg) {//GEN-LINE:|7-commandAction|3|18-preAction // write pre-action user code here String mno=number.getString(); String msg=textUrdu.getString(); if(mno.equals("")) { alert = new Alert("Alert"); alert.setString("Enter Mobile Number!!!"); alert.setTimeout(2000); display.setCurrent(alert); } else { try { clientConn=(MessageConnection)Connector.open("sms://"+mno); } catch(Exception e) { alert = new Alert("Alert"); alert.setString("Unable to connect to Station because of network problem"); alert.setTimeout(2000); display.setCurrent(alert); } try { TextMessage textmessage = (TextMessage) clientConn.newMessage(MessageConnection.TEXT_MESSAGE); textmessage.setAddress("sms://"+mno); textmessage.setPayloadText(msg); clientConn.send(textmessage); } catch(Exception e) { Alert alert=new Alert("Alert","",null,AlertType.INFO); alert.setTimeout(Alert.FOREVER); alert.setString("Unable to send"); display.setCurrent(alert); } } //GEN-LINE:|7-commandAction|4|18-postAction // write post-action user code here }//GEN-BEGIN:|7-commandAction|5|7-postCommandAction }//GEN-END:|7-commandAction|5|7-postCommandAction // write post-action user code here }//GEN-BEGIN:|7-commandAction|6| //</editor-fold>//GEN-END:|7-commandAction|6| //<editor-fold defaultstate="collapsed" desc=" Generated Method: commandAction for Items ">//GEN-BEGIN:|8-itemCommandAction|0|8-preItemCommandAction /** * Called by a system to indicated that a command has been invoked on a * particular item. * * @param command the Command that was invoked * @param displayable the Item where the command was invoked */ public void commandAction(Command command, Item item) {//GEN-END:|8-itemCommandAction|0|8-preItemCommandAction // write pre-action user code here if (item == number) {//GEN-BEGIN:|8-itemCommandAction|1|21-preAction if (command == add) {//GEN-END:|8-itemCommandAction|1|21-preAction // write pre-action user code here //GEN-LINE:|8-itemCommandAction|2|21-postAction // write post-action user code here }//GEN-BEGIN:|8-itemCommandAction|3|28-preAction } else if (item == send) { if (command == select) {//GEN-END:|8-itemCommandAction|3|28-preAction // write pre-action user code here //GEN-LINE:|8-itemCommandAction|4|28-postAction // write post-action user code here }//GEN-BEGIN:|8-itemCommandAction|5|24-preAction } else if (item == textUrdu) { if (command == urdu) {//GEN-END:|8-itemCommandAction|5|24-preAction // write pre-action user code here if (isUrdu) isUrdu = false; else { isUrdu = true; TextField tf = (TextField)item; } //GEN-LINE:|8-itemCommandAction|6|24-postAction // write post-action user code here }//GEN-BEGIN:|8-itemCommandAction|7|8-postItemCommandAction }//GEN-END:|8-itemCommandAction|7|8-postItemCommandAction // write post-action user code here }//GEN-BEGIN:|8-itemCommandAction|8| //</editor-fold>//GEN-END:|8-itemCommandAction|8| //<editor-fold defaultstate="collapsed" desc=" Generated Getter: form ">//GEN-BEGIN:|14-getter|0|14-preInit /** * Returns an initialized instance of form component. * * @return the initialized component instance */ public Form getForm() { if (form == null) {//GEN-END:|14-getter|0|14-preInit // write pre-init user code here form = new Form("form", new Item[]{getNumber(), getTextUrdu(), getStringItem(), getSend()});//GEN-BEGIN:|14-getter|1|14-postInit form.addCommand(getExit()); form.addCommand(getSendMesg()); form.setCommandListener(this);//GEN-END:|14-getter|1|14-postInit // write post-init user code here form.setItemStateListener(this); // form.setCommandListener(this); }//GEN-BEGIN:|14-getter|2| return form; } //</editor-fold>//GEN-END:|14-getter|2| //<editor-fold defaultstate="collapsed" desc=" Generated Getter: number ">//GEN-BEGIN:|19-getter|0|19-preInit /** * Returns an initialized instance of number component. * * @return the initialized component instance */ public TextField getNumber() { if (number == null) {//GEN-END:|19-getter|0|19-preInit // write pre-init user code here number = new TextField("Number ", null, 11, TextField.PHONENUMBER);//GEN-BEGIN:|19-getter|1|19-postInit number.addCommand(getAdd()); number.setItemCommandListener(this); number.setDefaultCommand(getAdd());//GEN-END:|19-getter|1|19-postInit // write post-init user code here }//GEN-BEGIN:|19-getter|2| return number; } //</editor-fold>//GEN-END:|19-getter|2| //<editor-fold defaultstate="collapsed" desc=" Generated Getter: textUrdu ">//GEN-BEGIN:|22-getter|0|22-preInit /** * Returns an initialized instance of textUrdu component. * * @return the initialized component instance */ public TextField getTextUrdu() { if (textUrdu == null) {//GEN-END:|22-getter|0|22-preInit // write pre-init user code here textUrdu = new TextField("Message", null, 2000, TextField.ANY);//GEN-BEGIN:|22-getter|1|22-postInit textUrdu.addCommand(getUrdu()); textUrdu.setItemCommandListener(this);//GEN-END:|22-getter|1|22-postInit // write post-init user code here }//GEN-BEGIN:|22-getter|2| return textUrdu; } //</editor-fold>//GEN-END:|22-getter|2| //<editor-fold defaultstate="collapsed" desc=" Generated Getter: exit ">//GEN-BEGIN:|15-getter|0|15-preInit /** * Returns an initialized instance of exit component. * * @return the initialized component instance */ public Command getExit() { if (exit == null) {//GEN-END:|15-getter|0|15-preInit // write pre-init user code here exit = new Command("Exit", Command.EXIT, 0);//GEN-LINE:|15-getter|1|15-postInit // write post-init user code here }//GEN-BEGIN:|15-getter|2| return exit; } //</editor-fold>//GEN-END:|15-getter|2| //<editor-fold defaultstate="collapsed" desc=" Generated Getter: sendMesg ">//GEN-BEGIN:|17-getter|0|17-preInit /** * Returns an initialized instance of sendMesg component. * * @return the initialized component instance */ public Command getSendMesg() { if (sendMesg == null) {//GEN-END:|17-getter|0|17-preInit // write pre-init user code here sendMesg = new Command("send", Command.OK, 0);//GEN-LINE:|17-getter|1|17-postInit // write post-init user code here }//GEN-BEGIN:|17-getter|2| return sendMesg; } //</editor-fold>//GEN-END:|17-getter|2| //<editor-fold defaultstate="collapsed" desc=" Generated Getter: add ">//GEN-BEGIN:|20-getter|0|20-preInit /** * Returns an initialized instance of add component. * * @return the initialized component instance */ public Command getAdd() { if (add == null) {//GEN-END:|20-getter|0|20-preInit // write pre-init user code here add = new Command("add", Command.OK, 0);//GEN-LINE:|20-getter|1|20-postInit // write post-init user code here }//GEN-BEGIN:|20-getter|2| return add; } //</editor-fold>//GEN-END:|20-getter|2| //<editor-fold defaultstate="collapsed" desc=" Generated Getter: urdu ">//GEN-BEGIN:|23-getter|0|23-preInit /** * Returns an initialized instance of urdu component. * * @return the initialized component instance */ public Command getUrdu() { if (urdu == null) {//GEN-END:|23-getter|0|23-preInit // write pre-init user code here urdu = new Command("urdu", Command.OK, 0);//GEN-LINE:|23-getter|1|23-postInit // write post-init user code here }//GEN-BEGIN:|23-getter|2| return urdu; } //</editor-fold>//GEN-END:|23-getter|2| //<editor-fold defaultstate="collapsed" desc=" Generated Getter: stringItem ">//GEN-BEGIN:|25-getter|0|25-preInit /** * Returns an initialized instance of stringItem component. * * @return the initialized component instance */ public StringItem getStringItem() { if (stringItem == null) {//GEN-END:|25-getter|0|25-preInit // write pre-init user code here stringItem = new StringItem("string", null);//GEN-LINE:|25-getter|1|25-postInit // write post-init user code here }//GEN-BEGIN:|25-getter|2| return stringItem; } //</editor-fold>//GEN-END:|25-getter|2| //</editor-fold> //<editor-fold defaultstate="collapsed" desc=" Generated Getter: send ">//GEN-BEGIN:|26-getter|0|26-preInit /** * Returns an initialized instance of send component. * * @return the initialized component instance */ public StringItem getSend() { if (send == null) {//GEN-END:|26-getter|0|26-preInit // write pre-init user code here send = new StringItem("", "send", Item.BUTTON);//GEN-BEGIN:|26-getter|1|26-postInit send.addCommand(getSelect()); send.setItemCommandListener(this); send.setDefaultCommand(getSelect());//GEN-END:|26-getter|1|26-postInit // write post-init user code here }//GEN-BEGIN:|26-getter|2| return send; } //</editor-fold>//GEN-END:|26-getter|2| //<editor-fold defaultstate="collapsed" desc=" Generated Getter: select ">//GEN-BEGIN:|27-getter|0|27-preInit /** * Returns an initialized instance of select component. * * @return the initialized component instance */ public Command getSelect() { if (select == null) {//GEN-END:|27-getter|0|27-preInit // write pre-init user code here select = new Command("select", Command.OK, 0);//GEN-LINE:|27-getter|1|27-postInit // write post-init user code here }//GEN-BEGIN:|27-getter|2| return select; } //</editor-fold>//GEN-END:|27-getter|2| //<editor-fold defaultstate="collapsed" desc=" Generated Getter: task ">//GEN-BEGIN:|40-getter|0|40-preInit /** * Returns an initialized instance of task component. * * @return the initialized component instance */ public SimpleCancellableTask getTask() { if (task == null) {//GEN-END:|40-getter|0|40-preInit // write pre-init user code here task = new SimpleCancellableTask();//GEN-BEGIN:|40-getter|1|40-execute task.setExecutable(new org.netbeans.microedition.util.Executable() { public void execute() throws Exception {//GEN-END:|40-getter|1|40-execute // write task-execution user code here }//GEN-BEGIN:|40-getter|2|40-postInit });//GEN-END:|40-getter|2|40-postInit // write post-init user code here }//GEN-BEGIN:|40-getter|3| return task; } //</editor-fold>//GEN-END:|40-getter|3| /** * Returns a display instance. * @return the display instance. */ public Display getDisplay () { return Display.getDisplay(this); } /** * Exits MIDlet. */ public void exitMIDlet() { switchDisplayable (null, null); destroyApp(true); notifyDestroyed(); } /** * Called when MIDlet is started. * Checks whether the MIDlet have been already started and initialize/starts or resumes the MIDlet. */ public void startApp() { startMIDlet(); display.setCurrent(form); } /** * Called when MIDlet is paused. */ public void pauseApp() { midletPaused = true; } /** * Called to signal the MIDlet to terminate. * @param unconditional if true, then the MIDlet has to be unconditionally terminated and all resources has to be released. */ public void destroyApp(boolean unconditional) { } public void itemStateChanged(Item item) { if (item == textUrdu) { if (isUrdu) { stringItem.setText("urdu"); TextField tf = (TextField)item; String s = tf.getString(); char ch = s.charAt(s.length() - 1); s = s.substring(0, s.length() - 1); ch = Urdu.ToUrdu(ch); s = s + String.valueOf(ch); tf.setString(""); tf.setString(s); }//end if throw new UnsupportedOperationException("Not supported yet."); } } }

    Read the article

  • How to record / capture audio with RecordControl on Java ME, SE K770i

    - by tomaszs
    I want to record sound on my Java ME App on K770i. So I used this: http://java.sun.com/javame/reference/apis/jsr135/javax/microedition/media/control/RecordControl.html example of RecordControl in my code. It goes like this: import java.util.Vector; import javax.microedition.lcdui.Choice; import javax.microedition.lcdui.Command; import javax.microedition.lcdui.CommandListener; import javax.microedition.lcdui.Display; import javax.microedition.lcdui.Displayable; import javax.microedition.lcdui.List; import javax.microedition.media.Manager; import javax.microedition.media.MediaException; import javax.microedition.midlet.MIDlet; import java.io.*; import javax.microedition.lcdui.*; import javax.microedition.media.*; import javax.microedition.media.control.*; import javax.microedition.midlet.*; import javax.microedition.rms.*; (...) try { // Create a Player that captures live audio. Player p = Manager.createPlayer("capture://audio"); p.realize(); // Get the RecordControl, set the record stream, // start the Player and record for 5 seconds. RecordControl rc = (RecordControl)p.getControl("RecordControl"); ByteArrayOutputStream output = new ByteArrayOutputStream(); rc.setRecordStream(output); rc.startRecord(); p.start(); Thread.currentThread().sleep(5000); rc.commit(); p.close(); } catch (IOException ioe) { } catch (MediaException me) { } catch (InterruptedException ie) { } But unfortunately when I try to build it, it tells me: *** Creating directories *** *** Compiling source files *** ..\src\example\audiodemo\AudioPlayer.java:121: cannot find symbol symbol : class RecordControl location: class example.audiodemo.AudioPlayer RecordControl rc = (RecordControl)p.getControl("RecordControl"); ^ ..\src\example\audiodemo\AudioPlayer.java:121: cannot find symbol symbol : class RecordControl location: class example.audiodemo.AudioPlayer RecordControl rc = (RecordControl)p.getControl("RecordControl"); ^ 2 errors So my question is: why there is no RecordControl class if in documentations it is written this class should be there. Or is there other method to record / capture audio from microfone in Java ME of Sony Ericsson? How do you record sound?

    Read the article

  • How to get the stacktrace in a mobile device?

    - by Daniel Moura
    I'm getting a NullPointerException in a Nokia S40. I want to know what is causing this exception. The device shows: NullPointerException java/lang/NullPointerException This error only occurs in the device, running in the emulator the application works fine. I use microlog to debug my application. But the application works fine if the log is enabled. Is there a way to get the stack trace when I get this NullPointerException? I don't need all details like the line number just which method cause this exception. UPDATE: I installed the same application in another Nokia S40 and the same error didn't occur. Nokia 2660 - error Nokia 6131 - no error UPDATE 2: Somehow I find what was causing the NullPointerException. import javax.microedition.lcdui.Canvas; import javax.microedition.lcdui.Graphics; public class OuterClass extends Canvas { private Config config; public OuterClass() { this.config = new Config(); } public void paint(Graphics graphics) { HelperClass helper = new HelperClass(this.config); helper.doStuff(); } public void dispose() { this.config = null; } public class Config implements IConfig { public int getSomething() { // ... } } } public class HelperClass { private IConfig config; public HelperClass(IConfig) { this.config = config; } public doStuff() { config.getSomething(); // Here is thrown NullPointerException } } In some situations a thread is started and call the OuterClass.dispose() before the helper.doStuff() causing the NPE. I think when I enabled the log it made the thread slower and helper.doStuff() was called when I expected it to be called.

    Read the article

  • Need help regarding lwuit

    - by rajiv
    Hi, I have project, already developed using canvas and lib used is LCDUI. It's for nokia keyboard supported devices. Now I want to incorporate same application for touch devices. I have used touch methods like pointerpressed, etc. For normal functionality that worked pretty well. But it creates problem in commands. My application is in fullscreen mode. Commands I have created using user defined menu list. Probles is that I can not directly identify that which command has been clicked. Setting coordinates for every command is not thr feasible solution for me. I come across the new lib LWUIT, but i found out that it supports only forms(Can't we use on canvas?). and integrating LCDUI and LWUIT is also not possible(please give suggestion that can we use both in same application?). Is it possible to create form under canvas itself? Any other lib support available? thank you.

    Read the article

  • White screen between Canvases

    - by user315647
    Hello everyone, I am having, what i believe is a minor issue. I am developing a J2ME application which predominantly uses canvases for display. The problem is I have set all these canvases to fullscreen and when i navigate from one class to another i am first given a white screen and then taken to the canvas i intend to go. I am not understanding what i am doing wrong I am using the following statement for navigation javax.microedition.lcdui.Display.getDisplay(MIDlet).setCurrent(Canvas); Please help!!

    Read the article

  • In Netbeans 6.8 cant find org.netbeans package

    - by Rohit
    I have netbeans 6.8 with java ME platform setup on my ubuntu 9.10. My code requires the package org.netbeans.microedition.lcdui which is either not installed or not in the path. Surprising this runs perfectly in netbeans 6.8 on windows on my friend's pc. Is there any java ME plugin I need to install? Can somebody help me out with this? Thanks in advance.

    Read the article

  • error in midlet while implementing command..

    - by garima
    hi I have imported import com.sun.lwuit.Command; import javax.microedition.midlet.; import javax.microedition.lcdui.; in my code but still the following errors are coming... exitCommand = new Command("Exit", Command.EXIT, 2); //line 1 textbox.addCommand(exitCommand); //line 2 Command.EXIT cannot be resolved.. The method addCommand(Command) in the type Displayable is not applicable for the arguments (Command)

    Read the article

  • JavaME: Is it possible to run a MIDLet on a CDC configuration ?

    - by Leonel
    Hi, We have an application running on CLDC 1.1/MIDP 2.1, based on Midlets and lcdui. Is it possible to run the same application on CDC 1.1 with the PBP profile ? If so, where should I even start ? I'm using Sun WTK 3.0. With CLDC, the starting point is a JAD file, which indicates the name of the main midlet class. What is the starting point of an application on CDC ?

    Read the article

  • GPS with J2ME polish

    - by JV
    Hi all, I'm developing an GPS based application with J2ME and J2ME polish(2.1.2), i'm facing problems for accessing the location class. I'm getting the following exception Exception in thread "event-thread" java.lang.UnsatisfiedLinkError: aa.a(I)V Nokia/N95: at aa.a(Native Method) Nokia/N95: at ae.<clinit>(Unknown Source) Nokia/N95: at b.j(Unknown Source) Nokia/N95: at com.allstate.mini.MINIMidlet.commandAction(Unknown Source) Nokia/N95: at ax.b(Unknown Source) Nokia/N95: at u.b(Unknown Source) Nokia/N95: at al.d(Unknown Source) Nokia/N95: at bd.keyReleased(Unknown Source) Nokia/N95: at javax.microedition.lcdui.Display$KeyEvent.run(Display.java:158) Nokia/N95: at org.microemu.device.ui.EventDispatcher.post(EventDispatcher.java:144) Nokia/N95: at org.microemu.device.ui.EventDispatcher.run(EventDispatcher.java:74) Nokia/N95: at java.lang.Thread.run(Unknown Source) Please help...

    Read the article

  • Blackberry:How to add ChoiceGroup in VerticalFieldManager?

    - by user187532
    Hello Blackberry experts, I am having a VerticalFieldManager in my application home screen code and adding many fields into it. I would like to add Radio button (which is ChoiceGroup in BB) also into the screen. For that, i am adding ChoiceGroup code lines and trying to add to vertical manager like vfm.add(mChoices), but it is giving compilation error at this place as ....ui.Manager cannot be applied to ....lcdui.ChoiceGroup. Can't i add ChoiceGroup into Vertical Manager. If i use VerticalManager and adding many fields and would like to add Radio button also into it, How do i do that? Pleaes give your advise. Thanks.

    Read the article

  • Receive MMS images and make album using iamge using j2me

    - by Abdul Basit
    I am trying to made application which receive MMS images and make a album from them user can view the pictures while running this application. I am facing problem while running application on mobile. while this application is fully working in wireless tookit emulator. Please guide me to fix this problem.`//package hello; import javax.microedition.midlet.; import javax.microedition.lcdui.; import javax.wireless.messaging.*; import java.io.IOException; import java.util.Vector; import javax.microedition.io.Connector; import javax.microedition.lcdui.Display; //, ItemStateListener public class MMSS extends MIDlet implements CommandListener, Runnable, MessageListener { //-----------------------------------Receive MMS --------------------------- private Thread mReceiver = null; private boolean mEndNow = false; private Message msg = null; String msgReceived = null; private Image[] receivedImage = new Image[5]; private Command mExitCommand = new Command("Exit", Command.EXIT, 2); private Command mRedCommand = new Command("Back", Command.SCREEN, 1); private Command mBlueCommand = new Command("Next", Command.SCREEN, 1); private Command mPlay = new Command("Play", Command.SCREEN, 1); protected static final String DEFAULT_IMAGE = "/MMSS_logo.jpg"; //protected static final String DEFAULT_IMAGE = "/wait.png"; private Display mDisplay = null; //protected ImageItem mColorSquare = null; protected Image mInitialImage = null; private String mAppID = "MMSMIDlet"; private TextField imageName = null; //private Form mForm = null; private int count = 0; private int next = 0; private Integer mMonitor = new Integer(0); //----------------------------------- End Receive MMS --------------------------- private boolean midletPaused = false; private Command exitCommand; private Command exitCommand1; private Command backCommand; private Form form; private StringItem stringItem; private ImageItem imageItem; private Image image1; private Alert alert; private List locationList; private Alert cannotAddLocationAlert; public MMSS() { } /** * Initilizes the application. * It is called only once when the MIDlet is started. The method is called before the startMIDlet method. */ private void initialize() { } /** * Performs an action assigned to the Mobile Device - MIDlet Started point. */ public void startMIDlet() { // write pre-action user code here switchDisplayable(null, getForm()); // write post-action user code here } /** * Performs an action assigned to the Mobile Device - MIDlet Resumed point. */ public void resumeMIDlet() { } /** * Switches a current displayable in a display. The display instance is taken from getDisplay method. This method is used by all actions in the design for switching displayable. * @param alert the Alert which is temporarily set to the display; if null, then nextDisplayable is set immediately * @param nextDisplayable the Displayable to be set / public void switchDisplayable(Alert alert, Displayable nextDisplayable) {//GEN-END:|5-switchDisplayable|0|5-preSwitch // write pre-switch user code here Display display = getDisplay();//GEN-BEGIN:|5-switchDisplayable|1|5-postSwitch if (alert == null) { display.setCurrent(nextDisplayable); } else { display.setCurrent(alert, nextDisplayable); } } /* * Called by a system to indicated that a command has been invoked on a particular displayable. * @param command the Command that was invoked * @param displayable the Displayable where the command was invoked */ public void commandAction(Command command, Displayable displayable) { // write pre-action user code here if (displayable == form) { if (command == exitCommand) { // write pre-action user code here exitMIDlet(); // write post-action user code here } } // write post-action user code here } /** * Returns an initiliazed instance of exitCommand component. * @return the initialized component instance */ public Command getExitCommand() { if (exitCommand == null) { // write pre-init user code here exitCommand = new Command("Exit", Command.EXIT, 0); // write post-init user code here } return exitCommand; } /** * Returns an initiliazed instance of form component. * @return the initialized component instance */ public Form getForm() { if (form == null) { // write pre-init user code here form = new Form("Welcome to MMSS", new Item[] { getStringItem(), getImageItem() }); form.addCommand(getExitCommand()); form.setCommandListener(this); // write post-init user code here } return form; } /** * Returns an initiliazed instance of stringItem component. * @return the initialized component instance */ public StringItem getStringItem() { if (stringItem == null) { // write pre-init user code here stringItem = new StringItem("Hello", "Hello, World!"); // write post-init user code here } return stringItem; } /** * Returns an initiliazed instance of exitCommand1 component. * @return the initialized component instance / public Command getExitCommand1() { if (exitCommand1 == null) { // write pre-init user code here exitCommand1 = new Command("Exit", Command.EXIT, 0); // write post-init user code here } return exitCommand1; } /* * Returns an initiliazed instance of imageItem component. * @return the initialized component instance */ public ImageItem getImageItem() { if (imageItem == null) { // write pre-init user code here imageItem = new ImageItem("imageItem", getImage1(), ImageItem.LAYOUT_CENTER | Item.LAYOUT_TOP | Item.LAYOUT_BOTTOM | Item.LAYOUT_VCENTER | Item.LAYOUT_EXPAND | Item.LAYOUT_VEXPAND, "");//GEN-LINE:|26-getter|1|26-postInit // write post-init user code here } return imageItem; } /** * Returns an initiliazed instance of image1 component. * @return the initialized component instance */ public Image getImage1() { if (image1 == null) { // write pre-init user code here try { image1 = Image.createImage("/B.jpg"); } catch (java.io.IOException e) { e.printStackTrace(); } // write post-init user code here } return image1; } /** * Returns a display instance. * @return the display instance. */ public Display getDisplay () { return Display.getDisplay(this); } /** * Exits MIDlet. */ public void exitMIDlet() { switchDisplayable (null, null); destroyApp(true); notifyDestroyed(); } /** * Called when MIDlet is started. * Checks whether the MIDlet have been already started and initialize/starts or resumes the MIDlet. */ public void startApp() { if (midletPaused) { resumeMIDlet (); } else { initialize (); startMIDlet (); } midletPaused = false; /////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////// try { conn = (MessageConnection) Connector.open("mms://:" + mAppID); conn.setMessageListener(this); } catch (Exception e) { System.out.println("startApp caught: "); e.printStackTrace(); } if (conn != null) { startReceive(); } /////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////// } /** * Called when MIDlet is paused. */ public void pauseApp() { midletPaused = true; mEndNow = true; try { conn.setMessageListener(null); conn.close(); } catch (IOException ex) { System.out.println("pausetApp caught: "); ex.printStackTrace(); } } /** * Called to signal the MIDlet to terminate. * @param unconditional if true, then the MIDlet has to be unconditionally terminated and all resources has to be released. */ public void destroyApp(boolean unconditional) { mEndNow = true; try { conn.close(); } catch (IOException ex) { System.out.println("destroyApp caught: "); ex.printStackTrace(); } } private void startReceive() { mEndNow = false; //---- Start receive thread mReceiver = new Thread(this); mReceiver.start(); } protected MessageConnection conn = null; protected int mMsgAvail = 0; // -------------------- Get Next Images ------------------------------------ private void getMessage() { synchronized(mMonitor) { mMsgAvail++; mMonitor.notify(); } } // -------------------- Display Images Thread ------------------------------ public void notifyIncomingMessage(MessageConnection msgConn) { if (msgConn == conn) getMessage(); } public void itemStateChanged(Item item) { throw new UnsupportedOperationException("Not supported yet."); } class SetImage implements Runnable { private Image img = null; public SetImage(Image inImg) { img = inImg; } public void run() { imageItem.setImage(img); imageName.setString(Integer.toString(count)); } } public void run() { mMsgAvail = 0; while (!mEndNow) { synchronized(mMonitor) { // Enter monitor if (mMsgAvail <= 0) try { mMonitor.wait(); } catch (InterruptedException ex) { } mMsgAvail--; } try { msg = conn.receive(); if (msg instanceof MultipartMessage) { MultipartMessage mpm = (MultipartMessage)msg; MessagePart[] parts = mpm.getMessageParts(); if (parts != null) { for (int i = 0; i < parts.length; i++) { MessagePart mp = parts[i]; byte[] ba = mp.getContent(); receivedImage[count] = Image.createImage(ba, 0, ba.length); } Display.getDisplay(this).callSerially(new SetImage(receivedImage[count])); } } } catch (IOException e) { System.out.println("Receive thread caught: "); e.printStackTrace(); } count++; } // of while } } `

    Read the article

  • image not displaying in midlet

    - by user316843
    Hello all,am new here. i have a slight problem; PLease look at the following code and tell me if am doing something wrong because the image is not displaying. i have made it really small so it should fit but its not displaying. i have images displaying in other screens but this main midlet would not. Here is the code: import java.io.IOException; import javax.microedition.midlet.*; import javax.microedition.lcdui.*; /** * @author jay */ public class WShop extends MIDlet implements CommandListener { /* Declare display variables*/ private Form mainForm; private Display display; private Command OK,Exit,wView, mView, myView; /* */ Categories categories = new Categories(this); Image image; public WShop() { /* initialize Screen and Command buttons that will be used when the application starts in the class constructor*/ mainForm = new Form("Wind Shopper"); OK = new Command("OK", Command.OK, 2); Exit = new Command("Exit", Command.EXIT, 0); wview= new Command("wview", Command.OK, 0); mview= new Command("mview", Command.OK, 0); try { /* retrieving the main image of the application*/ image = Image.createImage("/main.png"); } catch (IOException ex) { ex.printStackTrace(); } mainForm.addCommand(OK); mainForm.addCommand(Exit); mainForm.addCommand(wView); mainForm.addCommand(mView); mainForm.setCommandListener(this); } public void startApp() { /* checks to see if the display is currently empty and then sets it to the current screen */ if (display == null) { display = Display.getDisplay(this); } display.setCurrent(mainForm); } /* paused state of the application*/ public void pauseApp() { } /* Destroy Midlet state*/ public void destroyApp(boolean unconditional) { } Thanks in advance.

    Read the article

  • JME: How to get the complete screen in WHITE without buttons, etc etc

    - by Sepala
    Please have a look at the following code /* * To change this template, choose Tools | Templates * and open the template in the editor. */ import javax.microedition.midlet.*; import javax.microedition.lcdui.*; /** */ public class Midlet extends MIDlet{ private Form f; private Display d; private Command start,stop; private Thread t; public Midlet() { t = new Thread(new TurnLightOn()); } public void startApp() { f = new Form("Back Light On"); d = Display.getDisplay(this); d.setCurrent(f); start = new Command("Turn On",Command.OK,0); stop = new Command("Turn Off",Command.OK,1); f.addCommand(start); f.setCommandListener(new Action()); } public void pauseApp() { } public void destroyApp(boolean unconditional) { this.notifyDestroyed(); } private class Action implements CommandListener { public void commandAction(Command c, Displayable dis) { f.append("Light is Turnning On"); t.start(); } } private class ActionOff implements CommandListener { public void commandAction(Command c, Displayable dis) { } } private class TurnLightOn implements Runnable { public void run() { f.append("Working"); for(int i=0;i<100;i++) { try { d.flashBacklight(200); d.vibrate(200); Thread.sleep(1000); } catch (InterruptedException ex) { ex.printStackTrace(); } } } } } First, Please note I am a 100% newbie to Java Mobile. In here, I am making the light on and vibrate on when user click the button. However, I really wanted to create a SOS application which turn the whole screen into white, and go to black, like that, in the thread. I guess I didn't achieve that by this app because even the lights are on, the buttons are still there. I tried to turn the "Form" color to "white" but it seems like JME has no "Color" class! Please help!

    Read the article

  • Blackberry: Getting uncaught exception java.lang.securityexception

    - by Maxim Xion
    here is my code to open an image file from SDcard in Blackberry import javax.microedition.midlet.*; import javax.microedition.lcdui.*; import java.io.*; public class DisplayAnImage extends MIDlet { private Display mDisplay; private Form mForm; private Image pngBackground; public void startApp() { try{ pngBackground = Image.createImage("file:///Media Card/test_image.png"); ImageItem img = new ImageItem("bg",pngBackground, ImageItem.LAYOUT_EXPAND,"background",ImageItem.PLAIN); mForm = new Form("MIDlet Developer Guide: Display an image."); mForm.append(img); mDisplay = Display.getDisplay(this); mDisplay.setCurrent(mForm); } catch(IOException e) { mForm.append(e.getMessage()); } } public void pauseApp() { } public void destroyApp(boolean flag) { } } While I am running this app with giving all permission to app it shows me "uncaught exception java.lang.securityexception". Please somebody help me on this. Thanks in advance.. :-)

    Read the article

  • unable to capture picture using camera in j2me polish?

    - by SIVAKUMAR.J
    I'm, developing a mobile app in j2me.Now im converting it into j2me polish. In my app I capture a picture using camera in mobile phone. It works fine in j2me. But it does not work fine in j2me polish. I cannot resolve it. The code snippet given below public class VideoCanvas extends Canvas { // private VideoMIDlet midlet; // Form frm Form frm=null; public VideoCanvas(VideoControl videoControl) { int width = getWidth(); int height = getHeight(); // this.midlet = midlet; //videoControl.initDisplayMode(VideoControl.USE_DIRECT_VIDEO, this); //Canvas canvas = StyleSheet.currentScreen; //canvas = MasterCanvas.instance; videoControl.initDisplayMode( VideoControl.USE_DIRECT_VIDEO,this); try { videoControl.setDisplayLocation(2, 2); videoControl.setDisplaySize(width - 4, height - 4); } catch (MediaException me) {} videoControl.setVisible(true); } public VideoCanvas(VideoControl videoControl,Form ff) { frm=ff; int width = getWidth(); int height = getHeight(); // this.midlet = midlet; Ticker ticker=new Ticker("B4 video controll init"); frm.setTicker(ticker); //Canvas canvas = StyleSheet.currentScreen; videoControl.initDisplayMode(VideoControl.USE_DIRECT_VIDEO,this); ticker=new Ticker("after video controll init"); frm.setTicker(ticker); try { videoControl.setDisplayLocation(2, 2); videoControl.setDisplaySize(width - 4, height - 4); } catch (MediaException me) {} videoControl.setVisible(true); ticker=new Ticker("Device not supported"); frm.setTicker(ticker); } public void paint(Graphics g) { int width = getWidth(); int height = getHeight(); g.setColor(0x00ff00); g.drawRect(0, 0, width - 1, height - 1); g.drawRect(1, 1, width - 3, height - 3); } } In normal j2me the above code works correctly. But in j2me polish videoControl.initDisplayMode(VideoControl.USE_DIRECT_VIDEO,this) here this refers to VideoCanvas (which extends from javax.microedition.lcdui.Canvas). But it throws an "IllegalArgumentException - container should be canvas" like that. How to solve the issue?

    Read the article

  • j2me bluetooth client. Function startInquiry nothing found.

    - by Hugi
    I develop simple j2me bluetooth client and have problem with bluetooth device search. Function startInquiry nothing found. Client : nokia 5220 Server : my pc with bluetooth adapter All bluetooth devices is on. /* * To change this template, choose Tools | Templates * and open the template in the editor. */ import javax.microedition.midlet.*; import javax.bluetooth.*; import java.util.Vector; import javax.microedition.lcdui.*; /** * @author ????????????? */ public class Midlet extends MIDlet implements DiscoveryListener { private static Vector vecDevices=new Vector(); private static String connectionURL=null; private LocalDevice localDevice; private DiscoveryAgent agent; private RemoteDevice remoteDevice; private RemoteDevice[] devList; private Display display; private Form form; public void startApp() { display = Display.getDisplay(this); form = new Form( "Client" ); try { localDevice = LocalDevice.getLocalDevice(); } catch( BluetoothStateException e ) { e.printStackTrace(); } form.append("Address: "+localDevice.getBluetoothAddress()+"\n\n"); form.append("Name: "+localDevice.getFriendlyName()+"\n\n"); try { agent = localDevice.getLocalDevice().getDiscoveryAgent(); form.append("Starting device inquiry... \n\n"); boolean si = agent.startInquiry(DiscoveryAgent.GIAC, this); if ( si ) { form.append("true"); } else { form.append("false"); } } catch( BluetoothStateException e ) { } int deviceCount = vecDevices.size(); if(deviceCount <= 0){ form.append("No Devices Found ."); } else{ //print bluetooth device addresses and names in the format [ No. address (name) ] form.append("Bluetooth Devices: "); for (int i = 0; i < deviceCount; i++) { remoteDevice=(RemoteDevice)vecDevices.elementAt(i); form.append( remoteDevice.getBluetoothAddress() ); } } display.setCurrent(form); } public void pauseApp() { } public void destroyApp(boolean unconditional) { } public void deviceDiscovered(RemoteDevice btDevice, DeviceClass cod) { //add the device to the vector if(!vecDevices.contains(btDevice)){ vecDevices.addElement(btDevice); } } public void inquiryCompleted(int discType) { } //implement this method since services are not being discovered public void servicesDiscovered(int transID, ServiceRecord[] servRecord) { if(servRecord!=null && servRecord.length>0){ connectionURL=servRecord[0].getConnectionURL(0,false); } } //implement this method since services are not being discovered public void serviceSearchCompleted(int transID, int respCode) { } }

    Read the article

  • How to read URDU from url and show it to your mobile using java Me

    - by Basit
    HI, Hope you all will be fine. Actually I m facing a problem. Actually i am using Google translation API. What my application does it connect to CGI-script, i pass value to it using GET then the CGI script connect to Google API, Translate the mesage from english to Urdu and then i retreive it.Here is the code [Java] import java.io.*; import javax.microedition.io.*; import javax.microedition.lcdui.*; import javax.microedition.midlet.*; /** * An example MIDlet to invoke a CGI script (GET method). */ public class InvokeCgiMidlet1 extends MIDlet { private Display display; String url = "http://xxx.xxx.xx.xxx/cgi-bin/api/GT/GT_Send_Msg.cgi?message=my%20name%20is%20basit"; public InvokeCgiMidlet1() { display = Display.getDisplay(this); } /** * Initialization. Invoked when we activate the MIDlet. */ public void startApp() { try { getGrade(url); } catch (IOException e) { System.out.println("IOException " + e); e.printStackTrace(); } } /** * Pause, discontinue .... */ public void pauseApp() { } /** * Destroy must cleanup everything. */ public void destroyApp(boolean unconditional) { } /** * Retrieve a grade.... */ void getGrade(String url) throws IOException { HttpConnection c = null; InputStream is = null; OutputStream os = null; StringBuffer b = new StringBuffer(); TextBox t = null; String response; try { c = (HttpConnection)Connector.open(url, Connector.READ_WRITE); c.setRequestMethod(HttpConnection.GET); c.setRequestProperty("User-Agent","Profile/MIDP-1.0 Confirguration/CLDC-1.0"); c.setRequestProperty("Content-Type","application/x-www-form-urlencoded"); c.setRequestProperty("User-Agent","Profile/MIDP-2.0 Configuration/CLDC-1.1"); c.setRequestProperty("Accept-Charset","UTF-8;q=0.7,*;q=0.7"); c.setRequestProperty("Accept-Encoding","gzip, deflate"); c.setRequestProperty("Accept","text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5"); c.setRequestProperty("Content-Language", "en-EN"); os = c.openOutputStream(); Reader r = new InputStreamReader(c.openDataInputStream(), "UTF-8"); int ch; while ((ch = r.read()) != -1) { b.append((char) ch ); //System.out.println((char)ch + "->" + ch + "->" + ch); } t = new TextBox("Final Grades", b.reverse().toString(), 1024, 0); } finally { if(is!= null) { is.close(); } if(os != null) { os.close(); } if(c != null) { c.close(); } } display.setCurrent(t); } } [/Java] The problem is as i told you that the translated text is in Urdu. So when it appear on screen each character is separate like this. ? ?? ? ? ?? . Because i read character by character I want it to appear in proper form like this ??????? So how can i do this. Is there font rendering required. If yes then how can i do it or any other method please hep me. Thanks

    Read the article

  • Java ME scorecard with vector and multiple input fields/screens

    - by proximity
    I have made a scorecard with 5 holes, for each a input field (shots), and a image is shown. The input should be saved into a vector and shown on each hole, eg. hole 2: enter shots, underneath it "total shots: 4" (if you have made 4 shots on hole 1). In the end I would need a sum up of all shots, eg. Hole 1: 4 Hole 2: 3 Hole 3: 2 ... Total: 17 Could someone please help me with this task? { f = new Form("Scorecard"); d = Display.getDisplay(this); mTextField = new TextField("Shots:", "", 2, TextField.NUMERIC); f.append(mTextField); mStatus = new StringItem("Hole 1:", "Par 3, 480m"); f.append(mStatus); try { Image j = Image.createImage("/hole1.png"); ImageItem ii = new ImageItem("", j, 3, "Hole 1"); f.append(ii); } catch (java.io.IOException ioe) {} catch (Exception e) {} f.addCommand(mBackCommand); f.addCommand(mNextCommand); f.addCommand(mExitCommand); f.setCommandListener(this); Display.getDisplay(this).setCurrent(f); } public void startApp() { mBackCommand = new Command("Back", Command.BACK, 0); mNextCommand = new Command("Next", Command.OK, 1); mExitCommand = new Command("Exit", Command.EXIT, 2); } public void pauseApp() { } public void destroyApp(boolean unconditional) { } public void commandAction(Command c, Displayable d) { if (c == mExitCommand) { destroyApp(true); notifyDestroyed(); } else if ( c == mNextCommand) { // -> go to next hole input! save the mTextField input into a vector. } } } ------------------------------ Full code --------------------------------- import java.util.; import javax.microedition.midlet.; import javax.microedition.lcdui.*; public class ScorerMIDlet extends MIDlet implements CommandListener { private Command mExitCommand, mBackCommand, mNextCommand; private Display d; private Form f; private TextField mTextField; private Alert a; private StringItem mHole1; private int b; // repeat holeForm for all five holes and add the input into a vector or array. Display the values in the end after asking for todays date and put todays date in top of the list. Make it possible to go back in the form, eg. hole 3 - hole 2 - hole 1 public void holeForm(int b) { f = new Form("Scorecard"); d = Display.getDisplay(this); mTextField = new TextField("Shots:", "", 2, TextField.NUMERIC); f.append(mTextField); mHole1 = new StringItem("Hole 1:", "Par 5, 480m"); f.append(mHole1); try { Image j = Image.createImage("/hole1.png"); ImageItem ii = new ImageItem("", j, 3, "Hole 1"); f.append(ii); } catch (java.io.IOException ioe) {} catch (Exception e) {} // Set date&time in the end long now = System.currentTimeMillis(); DateField df = new DateField("Playing date:", DateField.DATE_TIME); df.setDate(new Date(now)); f.append(df); f.addCommand(mBackCommand); f.addCommand(mNextCommand); f.addCommand(mExitCommand); f.setCommandListener(this); Display.getDisplay(this).setCurrent(f); } public void startApp() { mBackCommand = new Command("Back", Command.BACK, 0); mNextCommand = new Command("OK-Next", Command.OK, 1); mExitCommand = new Command("Exit", Command.EXIT, 2); b = 0; holeForm(b); } public void pauseApp() {} public void destroyApp(boolean unconditional) {} public void commandAction(Command c, Displayable d) { if (c == mExitCommand) { destroyApp(true); notifyDestroyed(); } else if ( c == mNextCommand) { holeForm(b); } } }

    Read the article

  • Problem while running the j2me application

    - by Paru
    I am not able to view any content in the emulator while running the application. The Build is not failed and i am able run the application successfully. While i am closing the emulator i am getting an error. i can provide both code and log here. import javax.microedition.lcdui.; import javax.microedition.midlet.; import java.io.; import java.lang.; import javax.microedition.io.; import javax.microedition.rms.; public class Login extends MIDlet implements CommandListener { TextField ItemName=null; TextField ItemNo=null; TextField UserName=null; TextField Password=null; Form authForm,mainscreen; TextBox t = null; StringBuffer b = new StringBuffer(); private Display myDisplay = null; private Command okCommand = new Command("Login", Command.OK, 1); private Command exitCommand = new Command("Exit", Command.EXIT, 2); private Command sendCommand = new Command("Send", Command.OK, 1); private Command backCommand = new Command("Back", Command.BACK, 2); private Alert alert = null; public Login() { ItemName=new TextField("Item Name","",10,TextField.ANY); ItemNo=new TextField("Item No","",10,TextField.ANY); myDisplay = Display.getDisplay(this); UserName=new TextField("Your Name","",10,TextField.ANY); Password=new TextField("Password","",10,TextField.PASSWORD); authForm=new Form("Identification"); mainscreen=new Form("Logging IN"); mainscreen.addCommand(sendCommand); mainscreen.addCommand(backCommand); authForm.append(UserName); authForm.append(Password); authForm.addCommand(okCommand); authForm.addCommand(exitCommand); authForm.setCommandListener(this); myDisplay.setCurrent(authForm); } public void startApp() throws MIDletStateChangeException { } public void pauseApp() { } protected void destroyApp(boolean unconditional) throws MIDletStateChangeException { } public void commandAction(Command c, Displayable d) { if ((c == okCommand) && (d == authForm)) { if (UserName.getString().equals("") || Password.getString().equals("")){ alert = new Alert("Error", "You should enter Username and Password", null, AlertType.ERROR); alert.setTimeout(Alert.FOREVER); myDisplay.setCurrent(alert); } else{ //myDisplay.setCurrent(mainscreen); login(UserName.getString(),Password.getString()); } } if ((c == backCommand) && (d == mainscreen)) { myDisplay.setCurrent(authForm); } if ((c == exitCommand) && (d == authForm)) { notifyDestroyed(); } if ((c == sendCommand) && (d == mainscreen)) { if(ItemName.getString().equals("") || ItemNo.getString().equals("")){ } else{ sendItem(ItemName.getString(),ItemNo.getString()); } } } public void login(String UserName,String PassWord) { HttpConnection connection=null; DataInputStream in=null; String url="http://olario.net/submitpost/submitpost/login.php"; OutputStream out=null; try { connection=(HttpConnection)Connector.open(url); connection.setRequestMethod(HttpConnection.POST); connection.setRequestProperty("IF-Modified-Since", "2 Oct 2002 15:10:15 GMT"); connection.setRequestProperty("User-Agent","Profile/MIDP-1.0 Configuration/CLDC-1.0"); connection.setRequestProperty("Content-Language", "en-CA"); connection.setRequestProperty("Content-Length",""+ (UserName.length()+PassWord.length())); connection.setRequestProperty("username",UserName); connection.setRequestProperty("password",PassWord); out = connection.openDataOutputStream(); out.flush(); in = connection.openDataInputStream(); int ch; while((ch = in.read()) != -1) { b.append((char) ch); //System.out.println((char)ch); } //t = new TextBox("Reply",b.toString(),1024,0); //mainscreen.append(b.toString()); String auth=b.toString(); if(in!=null) in.close(); if(out!=null) out.close(); if(connection!=null) connection.close(); if(auth.equals("ok")){ mainscreen.setCommandListener(this); myDisplay.setCurrent(mainscreen); } } catch(IOException x){ } } public void sendItem(String itemname,String itemno){ HttpConnection connection=null; DataInputStream in=null; String url="http://www.olario.net/submitpost/submitpost/submitPost.php"; OutputStream out=null; try { connection=(HttpConnection)Connector.open(url); connection.setRequestMethod(HttpConnection.POST); connection.setRequestProperty("IF-Modified-Since", "2 Oct 2002 15:10:15 GMT"); connection.setRequestProperty("User-Agent","Profile/MIDP-1.0 Configuration/CLDC-1.0"); connection.setRequestProperty("Content-Language", "en-CA"); connection.setRequestProperty("Content-Length",""+ (itemname.length()+itemno.length())); connection.setRequestProperty("itemCode",itemname); connection.setRequestProperty("qty",itemno); out = connection.openDataOutputStream(); out.flush(); in = connection.openDataInputStream(); int ch; while((ch = in.read()) != -1) { b.append((char) ch); //System.out.println((char)ch); } //t = new TextBox("Reply",b.toString(),1024,0); //mainscreen.append(b.toString()); String send=b.toString(); if(in!=null) in.close(); if(out!=null) out.close(); if(connection!=null) connection.close(); if(send.equals("added")){ alert = new Alert("Error", "Send Successfully", null, AlertType.INFO); alert.setTimeout(Alert.FOREVER); myDisplay.setCurrent(alert); } } catch(IOException x){ } } } and the log is pre-init: pre-load-properties: exists.config.active: exists.netbeans.user: exists.user.properties.file: load-properties: exists.platform.active: exists.platform.configuration: exists.platform.profile: basic-init: cldc-pre-init: cldc-init: cdc-init: ricoh-pre-init: ricoh-init: semc-pre-init: semc-init: savaje-pre-init: savaje-init: sjmc-pre-init: sjmc-init: ojec-pre-init: ojec-init: cdc-hi-pre-init: cdc-hi-init: nokiaS80-pre-init: nokiaS80-init: nsicom-pre-init: nsicom-init: post-init: init: conditional-clean-init: conditional-clean: deps-jar: pre-preprocess: do-preprocess: Pre-processing 0 file(s) into /home/sreekumar/NetBeansProjects/Login/build/preprocessed directory. post-preprocess: preprocess: pre-compile: extract-libs: do-compile: post-compile: compile: pre-obfuscate: proguard-init: skip-obfuscation: proguard: post-obfuscate: obfuscate: lwuit-build: pre-preverify: do-preverify: post-preverify: preverify: pre-jar: set-password-init: set-keystore-password: set-alias-password: set-password: create-jad: add-configuration: add-profile: do-extra-libs: nokiaS80-prepare-j9: nokiaS80-prepare-manifest: nokiaS80-prepare-manifest-no-icon: nokiaS80-create-manifest: jad-jsr211-properties.check: jad-jsr211-properties: semc-build-j9: do-jar: nsicom-create-manifest: do-jar-no-manifest: update-jad: Updating application descriptor: /home/sreekumar/NetBeansProjects/Login/dist/Login.jad Generated "/home/sreekumar/NetBeansProjects/Login/dist/Login.jar" is 3501 bytes. sign-jar: ricoh-init-dalp: ricoh-add-app-icon: ricoh-build-dalp-with-icon: ricoh-build-dalp-without-icon: ricoh-build-dalp: savaje-prepare-icon: savaje-build-jnlp: post-jar: jar: pre-run: netmon.check: open-netmon: cldc-run: Copying 1 file to /home/sreekumar/NetBeansProjects/Login/dist/nbrun4244989945642509378 Copying 1 file to /home/sreekumar/NetBeansProjects/Login/dist/nbrun4244989945642509378 Jad URL for OTA execution: http://localhost:8082/servlet/org.netbeans.modules.mobility.project.jam.JAMServlet//home/sreekumar/NetBeansProjects/Login/dist//Login.jad Starting emulator in execution mode Running with storage root /home/sreekumar/j2mewtk/2.5.2/appdb/temp.DefaultColorPhone1 /home/sreekumar/NetBeansProjects/Login/nbproject/build-impl.xml:915: Execution failed with error code 143. BUILD FAILED (total time: 35 seconds)

    Read the article

  • Bluetooth connection. Problem with sony ericsson.

    - by Hugi
    I have bt client and server. Then i use method Connector.open, client connects to the port, but passed so that my server does not see them. Nokia for all normal, but with sony ericsson i have this problem. On bt adapter open one port (com 5). Listings Client /* * To change this template, choose Tools | Templates * and open the template in the editor. */ import java.util.Vector; import javax.bluetooth.*; import javax.microedition.midlet.*; import javax.microedition.lcdui.*; import javax.microedition.io.*; import java.io.*; /** * @author ????????????? */ public class Client extends MIDlet implements DiscoveryListener, CommandListener { private static Object lock=new Object(); private static Vector vecDevices=new Vector(); private ServiceRecord[] servRec = new ServiceRecord[INQUIRY_COMPLETED]; private Form form = new Form( "Search" ); private List voteList = new List( "Vote list", List.IMPLICIT ); private List vote = new List( "", List.EXCLUSIVE ); private RemoteDevice remoteDevice; private String connectionURL = null; protected int stopToken = 255; private Command select = null; public void startApp() { //view form Display.getDisplay(this).setCurrent(form); try { //device search print("Starting device inquiry..."); getAgent().startInquiry(DiscoveryAgent.GIAC, this); try { synchronized(lock){ lock.wait(); } }catch (InterruptedException e) { e.printStackTrace(); } //device count int deviceCount=vecDevices.size(); if(deviceCount <= 0) { print("No Devices Found ."); } else{ remoteDevice=(RemoteDevice)vecDevices.elementAt(0); print( "Server found" ); //create uuid UUID uuid = new UUID(0x1101); UUID uuids[] = new UUID[] { uuid }; //search service print( "Searching for service..." ); getAgent().searchServices(null,uuids,remoteDevice,this); } } catch( Exception e) { e.printStackTrace(); } } //if deivce discovered add to vecDevices public void deviceDiscovered(RemoteDevice btDevice, DeviceClass cod) { //add the device to the vector try { if(!vecDevices.contains(btDevice) && btDevice.getFriendlyName(true).equals("serverHugi")){ vecDevices.addElement(btDevice); } } catch( IOException e ) { } } public synchronized void servicesDiscovered(int transID, ServiceRecord[] servRecord) { //for each service create connection if( servRecord!=null && servRecord.length>0 ){ print( "Service found" ); connectionURL = servRecord[0].getConnectionURL(ServiceRecord.NOAUTHENTICATE_NOENCRYPT,false); //connectionURL = servRecord[0].getConnectionURL(ServiceRecord.AUTHENTICATE_NOENCRYPT,false); } if ( connectionURL != null ) { showVoteList(); } } public void serviceSearchCompleted(int transID, int respCode) { //print( "serviceSearchCompleted" ); synchronized(lock){ lock.notify(); } } //This callback method will be called when the device discovery is completed. public void inquiryCompleted(int discType) { synchronized(lock){ lock.notify(); } switch (discType) { case DiscoveryListener.INQUIRY_COMPLETED : print("INQUIRY_COMPLETED"); break; case DiscoveryListener.INQUIRY_TERMINATED : print("INQUIRY_TERMINATED"); break; case DiscoveryListener.INQUIRY_ERROR : print("INQUIRY_ERROR"); break; default : print("Unknown Response Code"); break; } } //add message at form public void print( String msg ) { form.append( msg ); form.append( "\n\n" ); } public void pauseApp() { } public void destroyApp(boolean unconditional) { } //get agent :))) private DiscoveryAgent getAgent() { try { return LocalDevice.getLocalDevice().getDiscoveryAgent(); } catch (BluetoothStateException e) { throw new Error(e.getMessage()); } } private synchronized String getMessage( final String send ) { StreamConnection stream = null; DataInputStream in = null; DataOutputStream out = null; String r = null; try { //open connection stream = (StreamConnection) Connector.open(connectionURL); in = stream.openDataInputStream(); out = stream.openDataOutputStream(); out.writeUTF( send ); out.flush(); r = in.readUTF(); print( r ); in.close(); out.close(); stream.close(); return r; } catch (IOException e) { } finally { if (stream != null) { try { stream.close(); } catch (IOException e) { } } return r; } } private synchronized void showVoteList() { String votes = getMessage( "c_getVotes" ); voteList.append( votes, null ); select = new Command( "Select", Command.OK, 4 ); voteList.addCommand( select ); voteList.setCommandListener( this ); Display.getDisplay(this).setCurrent(voteList); } private synchronized void showVote( int index ) { String title = getMessage( "c_getVote_"+index ); vote.setTitle( title ); vote.append( "Yes", null ); vote.append( "No", null ); vote.setCommandListener( this ); Display.getDisplay(this).setCurrent(vote); } public void commandAction( Command c, Displayable d ) { if ( c == select && d == voteList ) { int index = voteList.getSelectedIndex(); print( ""+index ); showVote( index ); } } } Use BlueCove in this program. Server /* * To change this template, choose Tools | Templates * and open the template in the editor. */ package javaapplication4; import java.io.*; import java.util.concurrent.locks.Lock; import java.util.concurrent.locks.ReentrantLock; import javax.bluetooth.*; import javax.microedition.io.*; import javaapplication4.Connect; /** * * @author ????????????? */ public class SampleSPPServer { protected static int endToken = 255; private static Lock lock=new ReentrantLock(); private static StreamConnection conn = null; private static StreamConnectionNotifier streamConnNotifier = null; private void startServer() throws IOException{ //Create a UUID for SPP UUID uuid = new UUID("1101", true); //Create the service url String connectionString = "btspp://localhost:" + uuid +";name=Sample SPP Server"; //open server url StreamConnectionNotifier streamConnNotifier = (StreamConnectionNotifier)Connector.open( connectionString ); while ( true ) { Connect ct = new Connect( streamConnNotifier.acceptAndOpen() ); ct.getMessage(); } } /** * @param args the command line arguments */ public static void main(String[] args) { //display local device address and name try { LocalDevice localDevice = LocalDevice.getLocalDevice(); localDevice.setDiscoverable(DiscoveryAgent.GIAC); System.out.println("Name: "+localDevice.getFriendlyName()); } catch( Throwable e ) { e.printStackTrace(); } SampleSPPServer sampleSPPServer=new SampleSPPServer(); try { //start server sampleSPPServer.startServer(); } catch( IOException e ) { e.printStackTrace(); } } } Connect /* * To change this template, choose Tools | Templates * and open the template in the editor. */ package javaapplication4; import java.io.*; import java.util.concurrent.locks.Lock; import java.util.concurrent.locks.ReentrantLock; import javax.bluetooth.*; import javax.microedition.io.*; /** * * @author ????????????? */ public class Connect { private static DataInputStream in = null; private static DataOutputStream out = null; private static StreamConnection connection = null; private static Lock lock=new ReentrantLock(); public Connect( StreamConnection conn ) { connection = conn; } public synchronized void getMessage( ) { Thread t = new Thread() { public void run() { try { in = connection.openDataInputStream(); out = connection.openDataOutputStream(); String r = in.readUTF(); System.out.println("read:" + r); if ( r.equals( "c_getVotes" ) ) { out.writeUTF( "vote1" ); out.flush(); } if ( r.equals( "c_getVote_0" ) ) { out.writeUTF( "Vote1" ); out.flush(); } out.close(); in.close(); } catch (Throwable e) { } finally { if (in != null) { try { in.close(); } catch (IOException e) { } } try { connection.close(); } catch( IOException e ) { } } } }; t.start(); } }

    Read the article

1