Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Emulator v.s. i88s device

 
Hannah Oh
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • 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();
}
 
Yuri Magrisso
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • 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 ]
 
Jeff Jetton
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
  • 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
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • 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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic