File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

paint() and applets

 
Shashank Gokhale
Ranch Hand
Posts: 92
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
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);
g.drawRect(1,1,15,80);
}
}
<html>
<head><title></title></head>
<body>
<applet code="paintit.class" height=??? width=""">
</applet>
</body>
</html>
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?
 
Marilyn de Queiroz
Sheriff
Posts: 9059
12
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
Shashank Gokhale
Ranch Hand
Posts: 92
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Marilyn,
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
Posts: 92
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Sheriff
Posts: 7023
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moving this to The Applets Forum...
 
Consider Paul's rocket mass heater.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic