×

Discussion Board

Results 1 to 10 of 10

Thread: Clickable Image

  1. #1
    Regular Contributor
    Join Date
    May 2009
    Posts
    59

    Smile Clickable Image

    Hi To All,

    I am newbie , so please help me... When we display an image (JPEG,PNG etc.), on the form or canvas.
    I cant explain in j2me terms , so explaining in j2se terms. For example In J2SE form (here in my case j2me form/canvas), when the user click on the image , we will handle the imageClick event and write the code as per requirement. What i want to say is ... Can we handle any events in j2me when the user clicks on the image. PLease help me.

    Thanks in Advance

  2. #2
    Super Contributor
    Join Date
    Apr 2007
    Posts
    2,708

    Re: Clickable Image

    there is no imageClick event...
    so I'm afraid you would ahve to work with a bounding box principle, self-implemented of course :P

  3. #3
    Regular Contributor
    Join Date
    May 2009
    Posts
    59

    Smile Re: Clickable Image

    Quote Originally Posted by Tiger79 View Post
    there is no imageClick event...
    so I'm afraid you would ahve to work with a bounding box principle, self-implemented of course :P

    sorry i am not talking of imageClick event, in the touch screen mobiles for example, after we display the image, is there any way that user select some area of the image, and we handle some event.

  4. #4
    Super Contributor
    Join Date
    Apr 2007
    Posts
    2,708

    Re: Clickable Image

    in J2ME you can handle a click of a touchscreen.. the event will passy ou the coordinates where the click occured...
    so it wont tell you the Image, it just will give you screen coordinates... its up to you to determine if those are on top of an Image...

  5. #5
    Super Contributor
    Join Date
    Mar 2008
    Location
    The Capital of INDIA
    Posts
    4,328

    Re: Clickable Image

    Quote Originally Posted by swarna.nokia View Post
    sorry i am not talking of imageClick event, in the touch screen mobiles for example, after we display the image, is there any way that user select some area of the image, and we handle some event.
    Yup,
    You would be having the clicked area's X and Y positions,Then you have to check that if the x value is so and so and y value is so and so,then do the this action.I means to say,is that there are the pointer pressed,released and dragged methods,in the same methods you would be getting the value of the x and y.Then as I said,you have to check the same values int the respective methods,

    is this make sense?
    Thanks with Regards,

    R a j - The K e r n e l


    Join Delhi-NCR Nokia Developer's Community,

  6. #6
    Regular Contributor
    Join Date
    May 2009
    Posts
    59

    Smile Re: Clickable Image

    Quote Originally Posted by raj_J2ME View Post
    Yup,
    You would be having the clicked area's X and Y positions,Then you have to check that if the x value is so and so and y value is so and so,then do the this action.I means to say,is that there are the pointer pressed,released and dragged methods,in the same methods you would be getting the value of the x and y.Then as I said,you have to check the same values int the respective methods,

    is this make sense?

    Sorry i didnt get you completely as i am new to J2ME, can you explain me in detail, with any code sinnept. Please.

    Thanks in Advance

  7. #7
    Super Contributor
    Join Date
    Mar 2008
    Location
    The Capital of INDIA
    Posts
    4,328

    Re: Clickable Image

    Hi,
    was better if you give a chance to Google to search the touch screen demo for you,
    Anyways this is the code that I have handy,
    Code:
    import java.io.IOException;
    import javax.microedition.lcdui.*;
    
    class PointerDemoCanvas extends Canvas implements Runnable
    {
         TouchScreenMidlet midelt = null;
         String eventType = "Press Pointer!";
         int x;
         int y;
         int sw;
         int sh;
         public PointerDemoCanvas(TouchScreenMidlet m)
         {
              this.midelt  = m;
              setFullScreenMode(true);
              sw= getWidth();
              sh = getHeight();
         }
         int imageX=0,imageY=0;
         public void pointerPressed(int x, int y)
         {
              eventType = "Pointer Pressed";
              this.x = x;
              this.y = y;
              repaint();
         }
         
         public void pointerReleased(int x, int y)
         {
              eventType = "Pointer Released";
              this.x = x;
              this.y = y;
              repaint();
         }
         
         public void pointerDragged(int x, int y)
         {
              eventType = "Pointer Repeated";
              this.x = x;
              this.y = y;
              repaint();
         }
         
         public void paint(Graphics g)
         {
              g.setGrayScale(0);
              g.fillRect(0, 0, getWidth(), getHeight());
              g.setGrayScale(255);
              g.drawString(eventType + " " +x +"/"+y,0, 0, Graphics.TOP|Graphics.LEFT);
              g.drawLine(x-4, y, x+4, y);
              g.drawLine(x, y-4, x, y+4);
              g.drawString("RAJIV",x,y,0);
         }
    }
    make a respective midlet and there create the object of this canvas set this as displayable,
    Last edited by raj_J2ME; 2009-06-19 at 13:02. Reason: remove thread concept in order to make simpler
    Thanks with Regards,

    R a j - The K e r n e l


    Join Delhi-NCR Nokia Developer's Community,

  8. #8
    Regular Contributor
    Join Date
    Jul 2008
    Location
    Faridabad(Delhi NCR)
    Posts
    343

    Re: Clickable Image

    Good job raj

    Hey swarna.nokia try this what raj is saying this will help you but first check the exact point where you image is display then handle your event between that point
    Anshu Chauhan
    J2me Developer

  9. #9
    Super Contributor
    Join Date
    Mar 2008
    Location
    The Capital of INDIA
    Posts
    4,328

    Smile Re: Clickable Image

    Hi Ansh,
    Thanks Man,
    Thanks with Regards,

    R a j - The K e r n e l


    Join Delhi-NCR Nokia Developer's Community,

  10. #10
    Regular Contributor
    Join Date
    Jul 2008
    Location
    Faridabad(Delhi NCR)
    Posts
    343

    Re: Clickable Image

    Welcome buddy
    Anshu Chauhan
    J2me Developer

Similar Threads

  1. --- ???save image problem??? ---
    By ferenn in forum Mobile Java Media (Graphics & Sounds)
    Replies: 6
    Last Post: 2007-10-01, 14:33
  2. Opening a JPEG Image
    By ummarbhutta in forum Mobile Java Media (Graphics & Sounds)
    Replies: 8
    Last Post: 2007-02-15, 06:34
  3. how to cut some part of Image
    By mshouab in forum Mobile Java Media (Graphics & Sounds)
    Replies: 2
    Last Post: 2006-08-04, 09:05
  4. HELP: Mutable Image to Immutable Image?
    By rj_cybersilver in forum Mobile Java Media (Graphics & Sounds)
    Replies: 1
    Last Post: 2005-03-26, 09:58
  5. Nokia Image Converter
    By davidpurdie in forum General Development Questions
    Replies: 0
    Last Post: 2004-02-18, 15:31

Posting Permissions

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