×

Discussion Board

Results 1 to 9 of 9
  1. #1
    Regular Contributor
    Join Date
    Jan 2009
    Posts
    88

    Basic Images in J2ME

    Hi,
    I have an application which just shows 3 pictures in a screen . But my problem is that these 3
    pictures are shown in random postions.What should i do so that i am able to place these images
    in the positions which i want?

  2. #2
    Super Contributor
    Join Date
    Jun 2003
    Location
    Cheshire, UK
    Posts
    7,395

    Re: Basic Images in J2ME

    Depends where you want them.

    With MIDP, you have two options for user interface.

    You can use the "high-level" Displayable classes, like Form and List. These do everything for you, but do it in their own way and give you little control.

    Or, you can use the "low-level" class Canvas. This gives you a lot of control, but you must do everything yourself. A Canvas receives events like paint() and keyPressed(), and will do nothing unless you handle these in your subclass.

    When using Canvas, make sure to call getWidth() and getHeight() to determine the size of the Canvas at run-time, so that your code can adjust to devices of different screen sizes. Also, use the sizeChanged() event to check when the size of the Canvas changes. This will happen particularly on devices like the N95, which works in both portrait and landscape mode, and can switch in the middle of running your application.

    Cheers,
    Graham.

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

    Re: Basic Images in J2ME

    Quote Originally Posted by littleson View Post
    Hi,
    I have an application which just shows 3 pictures in a screen .
    But my problem is that these 3
    pictures are shown in random postions.What should i do so that i am able to place these images
    in the positions which i want?
    Hi,
    Well,can you please tell me that are you working on the canvas or form...
    Now if you are using the for,..ok then you can not do more about it..as grahm already states that hoigh level API give you less control...

    better is that if you are using the canvas class...the you can do it simply...and follow like this.
    @ create the image image_name = Image.createImage();
    @ draw the image of the xOffsets and YOffsets,

    graphics.drawImage(xOffsets,yOffsets,Anchor);.

    @ Now assign the values to the xOFFsets and yOffsts as,where you want to draw the image.
    Thanks with Regards,

    R a j - The K e r n e l


    Join Delhi-NCR Nokia Developer's Community,

  4. #4
    Regular Contributor
    Join Date
    Jan 2009
    Posts
    88

    Re: Basic Images in J2ME

    Hi Graham,
    If i use Canvas i cannot use some of the facilities of the form..besides i need to click on the icons to
    go to another page..this , to my knowledge is not possible using canvas...isn't it so?

  5. #5
    Regular Contributor
    Join Date
    Jan 2009
    Posts
    88

    Re: Basic Images in J2ME

    Hi Raj,
    i am using form..i have seen some phone applications in which there is a background screen
    with some color and different icons on it which when clicked goes to another page...is this possible
    using canvas?

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

    Re: Basic Images in J2ME

    Quote Originally Posted by littleson View Post
    Hi Graham,
    If i use Canvas i cannot use some of the facilities of the form..besides i need to click on the icons to
    go to another page..this , to my knowledge is not possible using canvas...isn't it so?
    Hi,
    It can be done,in low level API.But you have to wrote the your custom controls.Therefore more work will be expected from you...
    Thanks with Regards,

    R a j - The K e r n e l


    Join Delhi-NCR Nokia Developer's Community,

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

    Re: Basic Images in J2ME

    Quote Originally Posted by littleson View Post
    Hi Raj,
    i am using form..i have seen some phone applications in which there is a background screen
    with some color and different icons on it which when clicked goes to another page...is this possible
    using canvas?
    Hi,
    Why not?
    You can draw your own menu(main) and sub menus...
    You have to more work by your self and has to develop the code by your own...
    Lets you have to make the menu kind of look and feel,then you have to draw the string and as well as the images you want to work as icon,
    Thanks with Regards,

    R a j - The K e r n e l


    Join Delhi-NCR Nokia Developer's Community,

  8. #8
    Super Contributor
    Join Date
    Jun 2003
    Location
    Cheshire, UK
    Posts
    7,395

    Re: Basic Images in J2ME

    Quote Originally Posted by littleson View Post
    Hi Graham,
    If i use Canvas i cannot use some of the facilities of the form..besides i need to click on the icons to
    go to another page..this , to my knowledge is not possible using canvas...isn't it so?
    Using Canvas, you can do anything you like... you just have to do all the work yourself.

    As I say, using Form is much easier, but you have less control.

    MIDP-2 adds two ways to have more control over a Form.

    1. Each item has a setLayout() method, that allows you to provide "layout directives" (though, these are more "hints" than "directives"). Take a look at the Java Docs for Item and for Form under the header "Layout". Layout directives allow you to tell the device whether you want things left, centre or right, and where you'd like line-breaks to appear. How much notice the device takes depends on the device.

    2. You can create a CustomItem. CustomItem is kind of like a "mini Canvas" that you can add inside a Form. Like a Canvas, you get events like paint() and keyPressed(), so you can control the appearance, and process input (while the item has focus). Since a CustomItem is an Item, you can append it to a Form, just like ImageItem or StringItem.

    Cheers,
    Graham.

  9. #9
    Regular Contributor
    Join Date
    Jan 2009
    Posts
    88

    Re: Basic Images in J2ME

    Hi ,
    Thanks a lot...I will look into your suggestions...

Similar Threads

  1. write an own j2me api?
    By Rozik in forum Mobile Java General
    Replies: 7
    Last Post: 2007-12-07, 14:11
  2. Incorrect rgb values for jpg images on S40 3rd ed
    By bjudfar in forum Mobile Java Media (Graphics & Sounds)
    Replies: 8
    Last Post: 2007-05-29, 16:34
  3. How can the WAP browser communicate to J2ME application?
    By hbfornies in forum Mobile Java General
    Replies: 20
    Last Post: 2007-03-02, 16:32
  4. need urgent guidance on j2me
    By cogni_niru in forum Mobile Java General
    Replies: 1
    Last Post: 2005-11-13, 15:02
  5. Images JPG in a J2ME mobile device
    By daldaver in forum Mobile Java Media (Graphics & Sounds)
    Replies: 1
    Last Post: 2003-08-05, 10:35

Posting Permissions

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