This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
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 Murach's Java Servlets and JSP this week in the Servlets 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,
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to invoke a paint method in Frame?
 
Similar Threads
UML HelloWorld
Error for AWT class
Haw to display painting in Panel
Can't run java HelloWorld
Can you give sample code to draw rectangle etc., etc.,?