Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

paint() and applets

 
Ranch Hand
Posts: 103
  • 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?
 
Sheriff
Posts: 9099
12
  • 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: 103
  • 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: 103
  • 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?
 
Sheriff
Posts: 7023
 
Don't get me started about those stupid light bulbs.
    Bookmark Topic Watch Topic
  • New Topic