🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.api
Article #1517

Re: newbie: graphics questions

#1517
From: Avi Abrami
Date: Wed, 21 Nov 2001 12:03
61 lines
3566 bytes
Markus Stehle wrote:

> Hi all!
>
> I�m new to Java development. I�m trying to write a little applet with a bar
> chart where the user can control each bar (currenlty 3 bars, the user can
> use his mouse to rise or lower each bar seperatly; rising or lowering one
> bar influences the other ones). Each bar is painted in a separate Canvas. To
> display the bars I use the fillRect() and clearRect() method of the Graphics
> object which is obtained from the different Canvases. My first problem is
> about applet initialzitaion: when the applet starts, three unfilled
> rectangles should be painted so that user can see something in his browser -
> not only a gray apllet box. When I call the myCanvas.getGraphics() and
> myGraphics.fillRect() method in my jbinit() method, I always get null
> pointer exceptions. I assume the objects are not already created while the
> constructor method is executed so I ca�n't access them. So where else can I
> call my methods? Is there something like an "applet loaded" event which I
> can catch and make my drawings there?
>
> My second question is about background images. How can I lay an image behind
> my bars? When I call the drawImage() method of the Graphics object and
> afterwards the drawRect() method, the image is positioned before the
> rectangle instead of behind.
>
> Thanks & Regards
>
> Markus

Hi Markus,
First, I would like to make two observations:

1. If you are new to java, you seem to be starting off
   with an awfully complex project!
2. From personal experience, java newcomers should
   really stay away from the JBuilder wizards until they
   have mastered the basics using first principals -- in
  other words, best to do everything yourself, without
   the help of the wizard.

Now to your question. Unfortunately, I can't really
give you an answer, but I see this is the second time
you're asking the same question (and you think
you'll get better luck if you try a different newsgroup)
so I thought I'd suggest something (a bit simpler than
what you're trying) with the hope that it will help
progress you toward your goal.

Anyway, the JDK comes with a sample applet
that displays an analog clock whose hands move
in real time (including a seconds hand, I think).
The source code is also available in the JDK,
so perhaps it can help you understand the use
of the Graphics class.

Also, are you familiar with JARS
(http://www.jars.com)? They may have applets
similar to what you are trying to do, which may
help you, also.

Good Luck,
Avi.
Technical Details
Message-ID: <3BFB981E.6722C34D@intersystemsww.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!supernews.com!news.tele.dk!small.news.tele.dk!4.1.16.34!cpk-news-hub1.bbnplanet.com!news.gtei.net!news.maxwell.syr.edu!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!dnews
References: <3bfb7529_1@dnews>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII
X-Google-Thread: 1089d0,f175a4535853b414
X-Google-Attributes: gid1089d0,public
X-Google-ArrivalTime: 2001-11-21 04:10:29 PST
Message-ID: <3BFB981E.6722C34D@intersystemsww.com>
Date: Wed, 21 Nov 2001 14:03:42 +0200
From: Avi Abrami <aabrami@intersystemsww.com>
Organization: InterSystems Ltd
X-Mailer: Mozilla 4.78 [en] (Windows NT 5.0; U)
X-Accept-Language: en
MIME-Version: 1.0
Newsgroups: borland.public.jbuilder.java.api
Subject: Re: newbie: graphics questions
References: <3bfb7529_1@dnews>
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: 8bit
NNTP-Posting-Host: 212.199.57.224
X-Trace: dnews 1006344143 212.199.57.224 (21 Nov 2001 04:02:23 -0800)
Lines: 64
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!supernews.com!news.tele.dk!small.news.tele.dk!4.1.16.34!cpk-news-hub1.bbnplanet.com!news.gtei.net!news.maxwell.syr.edu!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!dnews