🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.language
Article #16699

Re: Basically just an image.

#16699
From: Max Polk
Date: Fri, 22 Jan 1999 00:00
43 lines
1656 bytes
> I want to draw an image in memory (like you do in windows apps on the Canvas
> object). I just want to do simple draw operations like line, point,
> rectangle, circle, etc.
> How do I create the above. I have been looking at the 2D API, JFC, Java
> Advanced Imaging API....There are some methods, that I can use, but what I
> need is a general scope of how to do it...

Create a class that extends Panel and implements the paint method.  The 
paint method gets called when the Panel need to redraw.  Inside the paint 
method, use the Graphics object provided to you to do drawing and so 
forth.

Here is an example of an applet that draws using the paint method along 
with its HTML file:

// Sample.java
import java.applet.*;
import java.awt.*;

public class Sample extends Applet
{
  public void paint (Graphics g)
  {
    Dimension	dim = getSize ();
    int width = dim.width;
    int height = dim.height;

    g.fillOval(0, 0, width, height);
  }
}

// This is index.html
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
   <TITLE>Sample</TITLE>
</HEAD>
<BODY>

<applet code=Sample.class width=400 height=100></applet>

</BODY>
</HTML>
Technical Details
Message-ID: <MPG.1112fb3c924e7a379896ae@forums.borland.com>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <786piu$g143@forums.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f74b3,9497941a5492a426
X-Google-Attributes: gidf74b3,public
From: none@none.com (Max Polk)
Subject: Re: Basically just an image.
Date: 1999/01/22
Message-ID: <MPG.1112fb3c924e7a379896ae@forums.borland.com>
X-Deja-AN: 435857190
References: <786piu$g143@forums.borland.com>
Organization: Another Netscape Collabra Server User
Newsgroups: borland.public.jbuilder.java.language