This week's book giveaway is in the Web Services forum.
We're giving away four copies of Microservices in Action and have Morgan Bruce & Paulo A. Pereira on-line!
See this thread for details.
Win a copy of Microservices in Action this week in the Web Services forum!
  • 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
  • Bear Bibeault
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • paul wheaton
Saloon Keepers:
  • Ganesh Patekar
  • Frits Walraven
  • Tim Moores
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Stephan van Hulst
  • salvin francis
  • Tim Holloway

Emulator v.s. i88s device  RSS feed

 
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();
}
 
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 ]
 
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
 
ranger
Posts: 17314
11
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
Boost this thread!