×

Discussion Board

Results 1 to 2 of 2

Thread: Invalid anchor?

  1. #1
    Registered User
    Join Date
    Mar 2003
    Location
    Copenhagen, Denmark
    Posts
    18

    Invalid anchor?

    Hi guys,

    I've encountered a strange Exception in both the Nokia7210 SDK Emulator v1.0 and the actual Nokia7210 device.

    When I attempt to draw a String with an anchor of "Graphics.VCENTER | Graphics.HCENTER" an Exception is thrown: "java.lang.IllegalArgumentException Graphic: Invalid anchor. Anchor is: 3"

    However the Series40 MIDP SDK BETA 0.3 executes the code with no errors and it draws the string at the appropriate position on the screen.

    Have anyone experienced this error?

    Here is my code:

    private Font font = Font.getFont(Font.FACE_PROPORTIONAL, Font.STYLE_BOLD, Font.SIZE_MEDIUM);

    protected void paint(Graphics g){

    // Clear the screen
    g.setColor(0xffffff);
    g.fillRect(0, 0, getWidth(), getHeight());

    // Write "please wait" on to the screen.
    g.setFont(font);
    g.setColor(0);
    g.drawString("Please wait!", getWidth() / 2, getHeight() / 2, g.VCENTER | g.HCENTER);
    }

  2. #2
    Super Contributor
    Join Date
    Mar 2003
    Location
    Israel
    Posts
    2,280
    I've had the same problem. It was the Graphics.VCENTER. Apparently you can't use it in drawString(). So I didn't.

Posting Permissions

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