🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

ez-question (tm): drawing a rectangle

#17837
From: Paul Gifford
Date: Mon, 28 Sep 1998 00:00
34 lines
1394 bytes

  Ok...I'm new to Java and have been tinkering around with JBuilder 2.
I have an applet that has a BevelPanel at the top (north).  Below that
I draw 2 rectangles using this code:

  public void drawGrid()
  {
    Graphics g;

    g = this.getGraphics();

    g.setColor(Color.red);
    g.drawRect(200,200,50,50);

    g.setColor(Color.green);
    g.drawRect(205,205,50,50);
  }

  Simple enough.  When I run the applet, I see the rectangles flash
and disappear.  If I choose "Reload" from the "Applet" menu, they
appear...that is, until the Applet Viewer repaints itself (e.g. after
a minimize, or if it is brought to the front).  Then they're gone
again.

  I am calling this routine in the start() routine.  Is this not the
right place for code?  Is it possible the rectangles are being drawn
before the rest of the applet?  (which isn't much...just a panel).

  This seems so simple...yet the answer eludes me...

TIA

p
Technical Details
Message-ID: <360fff72.23835061@forums.inprise.com>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f74b3,2fedadf2f849da9e,start
X-Google-Attributes: gidf74b3,public
From: paul.gifford@ibm.take.me.outta.here.net (Paul Gifford)
Subject: ez-question (tm):  drawing a rectangle
Date: 1998/09/28
Message-ID: <360fff72.23835061@forums.inprise.com>
X-Deja-AN: 395763425
Organization: Another Netscape Collabra Server User
Newsgroups: borland.public.jbuilder.java.language