Discussion Board

Results 1 to 7 of 7
  1. #1
    I'm interest on developping apps in S40. And I plan to develop simple game on S40 devices.

    I wan't to draw some line in GameCanvas by overriding paint(Graphics g) method. The code seem like follow:

    public void paint(Graphics g) {
    g.setColor(255, 0, 0);
    g.drawLine(0, 0, getWidth(), getHeight());
    }


    I write the code for drawing diagonal line along the screen. But the line seems too thin. Is it possible to make it thicker. Somebody help me for this problem.

    Thanks.

  2. #2
    Nokia Developer Expert bandarap's Avatar
    Join Date
    May 2012
    Posts
    222
    Hi suhendrowansinaga and welcome to Nokia developer discussion boards,

    you can set line style using g.setStrokeStyle(SOLID or DOTTED) or if that is not enough then you can implement separate draw line as explained here for thickness

  3. #3
    Thanks a lot bandarap, it works nicely...

    I'have another problem. some body help...

    If i want to draw some string in J2ME, the code seems like follow
    g.drawString("Some String", getWidth()/2, getHeight()/2, Graphics.BASELINE | Graphics.HCENTER);
    Then the string appear on the screen. The default font looks like Times New Roman.

    In my app, I wan't to modify the font size and the font face.
    The font size that i want is big enough at about a half of the screen size, and the font face become others fonts. If It's possible, which API I should used for my problem?

    Thank you for the coming help.
    Last edited by suhendrowansinaga; 2012-07-04 at 08:03.

  4. #4
    Nokia Developer Expert bandarap's Avatar
    Join Date
    May 2012
    Posts
    222
    Hi suhendrowansinaga and you are welcome.

    you can set three default font sizes (SIZE_SMALL, SIZE_MEDIUM, SIZE_LARGE) as shown here. If default font sizes are not enough, you can use Nokia UI APIs 'com.nokia.mid.ui.DirectUtils' getFont(...) method. For more information see How to use freely resizable font in Java ME.

    Nokia UI APIs DirectUtils class can be found here.

  5. #5
    Thank a lot bandarap.

    Where can i download the Nokia UI APIs 'com.nokia.mid.ui.DirectUtils', i mean where can i get it?
    And how about the the font face? For example i want to draw some string with Comic Sans MS (for example) as it's font face?
    I have no idea for my problem.

    Help me please...
    Thanks for the coming help.

  6. #6
    Nokia Developer Expert bandarap's Avatar
    Join Date
    May 2012
    Posts
    222
    Nokia UI APIs 'com.nokia.mid.ui.DirectUtils' already included in the SDK and devices. You don’t have to download separately.

    The default font faces available in Java ME are:
    FACE_MONOSPACE, FACE_PROPORTIONAL and FACE_SYSTEM
    You can use font face, style and size like below:
    Font customFont=Font.getFont(Font.FACE_MONOSPACE, Font.STYLE_BOLD, Font.SIZE_LARGE);

    You cannot install a new font (for example Comic Sans MS) into the device using Java ME, but you can implement custom font as described in the wiki article How to create custom fonts in Java ME.

  7. #7
    Thanks bandarap, that's very helpfull,
    I'll start to implemented to my app

    I think my problem is solved, so far.

    Thank u

Similar Threads

  1. How to set border thickness of QListWidget
    By rahul.kulshreshtha in forum Qt
    Replies: 6
    Last Post: 2010-12-31, 13:12
  2. Line thickness
    By batora in forum Mobile Java General
    Replies: 2
    Last Post: 2010-02-17, 05:08
  3. Drawing a line with thickness using Java Mobile.
    By omgjingles in forum Mobile Java General
    Replies: 6
    Last Post: 2009-05-10, 18:13
  4. Replies: 5
    Last Post: 2008-09-23, 09:39
  5. Replies: 1
    Last Post: 2006-10-21, 05:32

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Nokia Developer aims to help you create apps and publish them so you can connect with users around the world.

京ICP备05048969号  © Copyright Nokia 2013 All rights reserved