File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes paint() and applets Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "paint() and applets" Watch "paint() and applets" New topic

paint() and applets

Shashank Gokhale
Ranch Hand

Joined: Jan 07, 2003
Posts: 92
When you draw something to the screen in a paint() method, you specify some coordinates. But then you have to include a height and width variable in your applet tag as well.
So how do you know how much the value of either the height or the width parameters should be in the applet tag? For example
import java.awt.Graphics;
import java.applet.Applet;
public class disp extends Applet
public void paint(Graphics g)
g.drawString("One a clock, two o clock, three a clock rock",10,40);
<applet code="paintit.class" height=??? width=""">
How do i know what the numbers for height and width need to be at the very minimum so that the entire applet is displayed on the screen and not cut off because the applet might be too big to be displayed in the size of the rectangle specified by height and width?

May the force of the Java be in all of us !!!
Marilyn de Queiroz

Joined: Jul 22, 2000
Posts: 9059
You want the height and width to be less than the parameters specified in the html page that calls your applet.
[ January 16, 2003: Message edited by: Marilyn de Queiroz ]

"Yesterday is history, tomorrow is a mystery, and today is a gift; that's why they call it the present." Eleanor Roosevelt
Shashank Gokhale
Ranch Hand

Joined: Jan 07, 2003
Posts: 92
So I guess what youre saying is that the rectangular area created on the screen by the height and the width specified in the java class has the same size and location as that created by the height and width attribute in an applet tag
am i right in assuming this?
Shashank Gokhale
Ranch Hand

Joined: Jan 07, 2003
Posts: 92
Another question, how can I know what the coordinates are that mark the four corners of my browser screen? That is, is it
(0,0) for the topleft
(0,700) for the topright
(600,0) for the bottomleft
(600,700) for the bottomright?
How do I find out this information? If I know this then I can display applets where on the screen I want to because I know what the coordinate ranges are, so is there a way to find this out?
Dirk Schreckmann

Joined: Dec 10, 2001
Posts: 7023
Moving this to The Applets Forum...

[How To Ask Good Questions] [JavaRanch FAQ Wiki] [JavaRanch Radio]
I agree. Here's the link:
subject: paint() and applets
It's not a secret anymore!