aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes How to invoke a paint method in Frame? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "How to invoke a paint method in Frame?" Watch "How to invoke a paint method in Frame?" New topic
Author

How to invoke a paint method in Frame?

Vanchi Nathan
Ranch Hand

Joined: Feb 24, 2004
Posts: 107
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.


Best regards,<br /> <br />vanchin
Basanth P Rangadhol
Greenhorn

Joined: Nov 22, 2004
Posts: 13
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...



Imagination is more important than knowledge - Einstien.
Vanchi Nathan
Ranch Hand

Joined: Feb 24, 2004
Posts: 107
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

Joined: Feb 24, 2004
Posts: 107
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,
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: How to invoke a paint method in Frame?