×

Discussion Board

Results 1 to 6 of 6
  1. #1
    Registered User
    Join Date
    Dec 2011
    Posts
    7

    J4ME: Issue in touch screen devices of nokia

    Hi,

    I am working on a J4ME application for touch screen device of Nokia. But touch motion is not proper working in my application. I am writing the code in pointer dragged and pointer Released method. Kindly give me any code or any solution of this issue.

  2. #2
    Nokia Developer Expert
    Join Date
    Aug 2011
    Posts
    555

    Re: J4ME: Issue in touch screen devices of nokia

    Hi shanu14 and welcome to Nokia's Discussion Boards,

    A sample code for what you need is this:

    The CanvasKeyPressed MIDlet:
    Code:
    import javax.microedition.midlet.*;
    import javax.microedition.lcdui.*;
    
    public class CanvasKeyPressed extends MIDlet implements CommandListener{
    	CanvasKey canvas;
    
      private Display display;
      Command cmd2=new Command("KeyPress2",Command.OK,0);
      
      public void startApp(){
      canvas = new CanvasKey();
      display = Display.getDisplay(this);
      display.setCurrent(canvas);
      canvas.addCommand(cmd2);
      canvas.setCommandListener(this);
      }
    
      public void pauseApp(){}
    
      public void destroyApp(boolean unconditional){}
    
      public void commandAction(Command c, Displayable d) 
      {
    	if(c==cmd2)
    	{
    		canvas.keyPressed(2);
    	}
    	
      }
      
    }
    The CanvasKey supporting java class:
    Code:
    import javax.microedition.lcdui.Canvas;
    import javax.microedition.lcdui.Font;
    import javax.microedition.lcdui.Graphics;
    
    
    class CanvasKey extends Canvas{
    
      private Font font;
      private String message = "[PRESS KEY]";
    
      public CanvasKey(){
      font = Font.getFont(Font.FACE_PROPORTIONAL, 
       Font.STYLE_PLAIN, Font.SIZE_MEDIUM);
      }
    
      public void mypress(int akey)
      {
    	  keyPressed(akey);
      }
      public void paint(Graphics g){
      int width = getWidth();
      int height = getHeight();
    
      g.setColor(255, 0, 0);
      g.fillRect(0, 0, width - 1, height - 1);
      g.setColor(0, 0, 255);
      g.drawRect(0, 0, width - 1, height - 1);
      g.setFont(font);
    
      int x = width / 2;
      int y = height / 2;
    
      g.drawString(message, x, y, Graphics.BASELINE | Graphics.HCENTER);
      }
      
    
      protected void keyPressed(int keyCode){
    	  message="KeyCode is "+keyCode;
    	  repaint();
      }
      protected void pointerPressed(int x, int y)
      {
    	 message="Pressed!";
    	 repaint();
      }
      protected void pointerReleased(int x, int y)
      {
    	  message="Released!";
    	  repaint();
      }
      
      protected void pointerDragged(int x, int y)
      {
    	  message="Dragged!";
    	  repaint();
      }
    
    }
    Make sure that you also check

    a) the Java ME examples in the wiki:
    http://www.developer.nokia.com/Commu...tegory:Java_ME

    b) the Touch UI articles in Java Developer's Library:
    http://library.developer.nokia.com/t...B166C077F.html

    c) the examples in the Library (including the multipoint touch event examples)
    http://library.developer.nokia.com/t...33A115191.html
    Last edited by skalogir; 2011-12-08 at 13:25.

  3. #3
    Registered User
    Join Date
    Dec 2011
    Posts
    7

    Re: J4ME: Issue in touch screen devices of nokia

    Hi skalogir,

    Thanks for reply.

    Actually I am working on a J4ME application for touch screen device of Nokia. But touch motion is not proper working in my application. I am writing the code in pointer dragged and pointer Released method. Kindly provide me any solution

  4. #4
    Nokia Developer Expert
    Join Date
    Aug 2011
    Posts
    555

    Re: J4ME: Issue in touch screen devices of nokia

    Hi shanu14,

    But touch motion is not proper working in my application
    Could you elaborate a bit more about the problem and the target device? It might be easier, if you could provide the code that is not working and a short description of what you need to do.

  5. #5
    Registered User
    Join Date
    Dec 2011
    Posts
    7

    Re: J4ME: Issue in touch screen devices of nokia

    Hi,

    Touch motion(J4ME) is not proper working(drag up and down) in 5230 and other devices also.

  6. #6
    Nokia Developer Expert
    Join Date
    Aug 2011
    Posts
    555

    Re: J4ME: Issue in touch screen devices of nokia

    I assume this is the same problem as the one you have opened here:

    http://www.developer.nokia.com/Commu...king-more-time

    I have already provided some suggestions on the above thread.

Similar Threads

  1. Replies: 2
    Last Post: 2011-04-07, 08:02
  2. Emulator for touch screen devices
    By conuil in forum Mobile Java Tools & SDKs
    Replies: 2
    Last Post: 2010-11-23, 11:59
  3. Issue in touch screen J2ME
    By junedahmed in forum Mobile Java General
    Replies: 1
    Last Post: 2010-05-03, 08:50
  4. Replies: 1
    Last Post: 2010-01-13, 11:29
  5. WRTkit and touch screen devices
    By hp3 in forum Symbian
    Replies: 3
    Last Post: 2009-06-30, 09:44

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×