my dog learned polymorphism
The moose likes Beginning Java and the fly likes Problem on drawing on panel Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Make it so: Java DB Connections & Transactions this week in the JDBC forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Problem on drawing on panel" Watch "Problem on drawing on panel" New topic

Problem on drawing on panel


Joined: May 12, 2001
Posts: 9
Can any one tell me how can i use draw string on panel
thanks in advance
shweta agarwal

Joined: Aug 30, 2001
Posts: 10
Text rending is sone using drawString method in Graphics class as:
void drawString( String str, int i, int j)
this draws the string str with i,j as the coordinates of the baseline of the first character in the string.
the above method can be used in conjunction with the getGraphics() method of the component class to solve your problem.
Rahul Mahindrakar
Ranch Hand

Joined: Jul 28, 2000
Posts: 1864
The Java Ranch has thousands of visitors every week, many with surprisingly similar names. To avoid confusion we have a naming convention, described at . We require names to have at least two words, separated by a space, and strongly recommend that you use your full real name. Please log in with a new name which meets the requirements.
Cindy Glass
"The Hood"

Joined: Sep 29, 2000
Posts: 8521
Put the code that shweta showed in the paint() method of the Panel ( you would probably want to sub-class Panel and make a MyPanel class that draws the string).

[This message has been edited by Cindy Glass (edited October 09, 2001).]

"JavaRanch, where the deer and the Certified play" - David O'Meara

Joined: May 12, 2001
Posts: 9
I will try and then reply
thanks to both shweta and cindy
I agree. Here's the link:
subject: Problem on drawing on panel
It's not a secret anymore!