Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to invoke a paint method in Frame?

 
Vanchi Nathan
Ranch Hand
Posts: 107
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello all,

I have tried a small program that extends a Frame class. the code is below, the paint method doesn't display the string, why? Any thing wrong? pl. help.


thanks in advance.
 
Basanth P Rangadhol
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hai...
the string was drawn, but was not visible... and also while overriding paint method, it is better to paint the super.paint(graphics g)... also, try avoiding paint() method... you can ue paintComponents() method...

 
Vanchi Nathan
Ranch Hand
Posts: 107
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Basanth,

I tried your code,

public void paint(Graphics g) { super.paint(g); g.drawString( ms, 20,40); }

but didn't work. I still can't see the string display on the frame.

Anyother way of doing?

regards,
 
Vanchi Nathan
Ranch Hand
Posts: 107
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello there!

Very sorry for the silly mistake... the co-ordinates were too small, hence the message got printed on the TitleBar. After changing it to higher values the message got displayed.

the code i tried is:
=========================


regards to all,
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic