[Logo]
Forums Register Login
Emulator v.s. i88s device
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();
}
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
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.
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 ]
 

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
"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

This thread has been viewed 855 times.

All times above are in ranch (not your local) time.
The current ranch time is
Sep 24, 2018 01:12:53.