• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Bear Bibeault
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Jj Roberts
  • Carey Brown
Bartenders:
  • salvin francis
  • Frits Walraven
  • Piet Souris

Emulator v.s. i88s device

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm trying to draw costomized checkList on Canvas and it works on Motorola iDEN Emulator. I use drawString, drawLine, drawRec. After downloading the application to Motorola i88s phone, a drawLine and drawRec is showing but the text no longer appears at Motorola i88s device.

Why isn't the text showing up?
Here is my code.

code:
----------------
public void paintArea(Graphics g, boolean hasFocus){
if(hasFocus){
g.setColor(150, 150, 150);
g.fillRect(x+15, y+2, w-18, h-6);
g.setStrokeStyle(Graphics.SOLID);
}

g.setColor(0,0,0);
g.setStrokeStyle(Graphics.SOLID);
g.setFont(Font.getFont(Font.FACE_SYSTEM, Font.STYLE_PLAIN, Font.SIZE_SMALL));
g.drawRect(x+4, y+4, 8, 8);
g.drawRect(x+5, y+5, 6, 6);

if(isSelected()){
g.drawLine(x+4, y+4, x+4+8, y+4+8);
g.drawLine(x+4+8, y+4, x+4, y+4+8);
}

g.drawString(getLabel(), x+17, y+4, Graphics.VCENTER | Graphics.LEFT);
repaint();
}
 
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Two ideas that might help:

Check whether 'getLabel()' doesn't return an empty string.

I am not sure that the 'repaint()' call belongs at the end of 'paintArea(..)'.
'paintArea()' is most likely called from the paint() method of Canvas. It doesn't make sense to call 'repaint()' just after you have actually repainted the screen.

Yuri
 
Hannah Oh
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you for your help ^^; getLabel() works properly because my coding can run at emulator very well and I send the information of getLabel() and all they are correct. I've tried to run withough repaint() but it still doesn't work.
 
Hannah Oh
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
g.drawString(getLabel(), x+17, y+4, Graphics.VCENTER | Graphics.LEFT);
==>g.drawString(getLabel(), x+17, y+4, Graphics.TOP | Graphics.LEFT);

I changed Graphics.VCENTER into Graphics.TOP and now it works!
According to MIDP1.0 specification,
Graphics.VCENTER: Constant for centering "IMAGES" vertically around the anchor point.
Graphics.HCENTER: Constant for centering "TEXT and IMAGES" horizontally around the anchor point.

I didn't realize that Graphics.VCENTER is not for centering "TEXT". Actually, VCENTER doesn't affect to run at Emulator but it does at real device! When you use this, BE CAREFUL! ^o^/

[ April 02, 2005: Message edited by: Conangirl Oh ]
[ April 02, 2005: Message edited by: Conangirl Oh ]
 
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

I didn't realize that Graphics.VCENTER is not for centering "TEXT". Actually, VCENTER doesn't affect to run at Emulator but it does at real device! When you use this, BE CAREFUL! ^o^/



I'll definitely file that little tidbit away. Thanks!

- Jeff
 
ranger
Posts: 17346
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"Conangirl oh"-
Welcome to the JavaRanch! Please adjust your displayed name to meet the

JavaRanch Naming Policy.

You can change it

here.

Thanks! and welcome to the JavaRanch!

Mark
 
And when my army is complete, I will rule the world! But, for now, I'm going to be happy with this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic