×

Discussion Board

Results 1 to 7 of 7
  1. #1
    Registered User
    Join Date
    Sep 2009
    Posts
    29

    how to chanage the position of the image

    I am bring the link from the servlet and then using it to display a image. I am able to display it but it show on the left top corner of my mobile device, i wan to show it in the center of the screen with specific size. how to do it?

    public void ViewLogo()
    {
    // HttpConnection httpConn = null;
    DataInputStream is = null;
    StringBuffer sb = new StringBuffer();
    Image img= null;

    System.out.println("Value of sResultLogooo:"+sResultLogo);
    String url = sResultLogo;

    System.out.println("URL :logo11 method:::"+url);
    try
    {

    HttpConnection httpConn1 = (HttpConnection) Connector.open(url);
    int len = (int)httpConn1.getLength();
    System.out.println("length logo:"+len);
    System.out.println("check logo::"+url);

    if (len > 0)
    {
    is = httpConn1.openDataInputStream();
    byte[] data = new byte[len];
    is.readFully(data);
    img = Image.createImage(data, 0, len);
    Form f = new Form("Logo");
    // ImageItem imgItem = new ImageItem("", img, ImageItem.LAYOUT_NEWLINE_AFTER | ImageItem.LAYOUT_CENTER, null);

    ImageItem imgItem = new ImageItem("",img,ImageItem.LAYOUT_RIGHT,null);
    f.addCommand(CMD_BackToViewCompanyProfileDetailsForm);
    f.append(imgItem);
    f.setCommandListener(this);
    display.setCurrent(f);
    }
    else
    {
    System.out.println("length is null");
    displayAlert("Information","No Image found.",AlertType.ERROR, mainForm, false);
    }
    is.close();
    httpConn1.close();
    }
    catch (Exception e)
    {
    e.printStackTrace();
    }
    }

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

    Re: how to chanage the position of the image

    It's an ImageItem which you append to a Form, so when you append it it will be placed on the next free available position of your Form.. With an empty Form that will be the first position which is located completely at the beginning of the Form (and your Screen)...
    To have it fully centralized on ypour screen you will have to use Canvas instead...
    There are though some formatting options available for Form items, but i'd refer you to the documentation (javadocs) for that, cause I can't remember it right away...

  3. #3
    Nokia Developer Champion
    Join Date
    Feb 2009
    Location
    Noida, India
    Posts
    3,087

    Re: how to chanage the position of the image

    Quote Originally Posted by j2me_beginner View Post
    I am bring the link from the servlet and then using it to display a image. I am able to display it but it show on the left top corner of my mobile device, i wan to show it in the center of the screen with specific size. how to do it?
    Please refer to: http://wiki.forum.nokia.com/index.ph...he_Screen_Size

    This article gives you code to resize the image based on your needs and how to place the image on the Canvas in the center.


    thanks,
    ~Amitabh
    (Poster of the Month -Aug'09)
    Follow me on my blog for Innovative Mobile Apps

  4. #4
    Registered User
    Join Date
    Sep 2009
    Posts
    29

    Re: how to chanage the position of the image

    thanks for your help.

  5. #5
    Registered User
    Join Date
    Sep 2009
    Posts
    29

    Re: how to chanage the position of the image

    can i use flash ? How to use it? or is there any other things which will help in showing images in good style?

  6. #6
    Nokia Developer Champion
    Join Date
    Feb 2009
    Location
    Noida, India
    Posts
    3,087

    Re: how to chanage the position of the image

    Quote Originally Posted by j2me_beginner View Post
    can i use flash ? How to use it? or is there any other things which will help in showing images in good style?
    If you want to display images within your J2me program with some 3D effects, explore and try to use LWUIT from SUN.

    thanks,
    ~Amitabh
    (Poster of the Month -Aug'09)
    Follow me on my blog for Innovative Mobile Apps

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

    Re: how to chanage the position of the image

    Well showing oogd Images is quite relative actually...
    You can make very good looking images yourself and then just show them in your app, for that you can use the Canvas...
    Or use a 3rd party GUI-library like LWUIT as mentioned above but also J2ME-Polish is an interesting package...
    About Flash, yes you can use Flash Lite ! But you have to take into account that first of all it's a Lite version, and second of all there are loads of versions (2.0, 2.1, 3.0) and that creates a device-fragmentation regarding Flash Lite support on the devices... Fortunately you can check and compare all Nokia device on this site and also check if and which version of Flash Lite is supported by which device !!!

Similar Threads

  1. Image Transparency issue - Help me out ....
    By tomcruise in forum Mobile Java Games
    Replies: 2
    Last Post: 2008-05-31, 15:40
  2. Image on a Form
    By ionutianasi in forum Mobile Java General
    Replies: 2
    Last Post: 2006-10-24, 11:04
  3. Drawing Lines on an Image (image graphics object returns null)
    By nicenouman in forum Mobile Java General
    Replies: 4
    Last Post: 2006-09-21, 10:15
  4. image transparency gets lost with DirectUtils.createImage
    By rawpsycho in forum Mobile Java Media (Graphics & Sounds)
    Replies: 5
    Last Post: 2003-05-28, 08:36
  5. Replies: 0
    Last Post: 2003-05-12, 17:38

Posting Permissions

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