🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.swing
Article #9491

Re: Set background after extending JPanel?

#9491
From: John P. McGrath
Date: Tue, 28 Mar 2000 00:00
28 lines
1466 bytes
On Mon, 27 Mar 2000 11:08:19 -0500, Trey Ethridge wrote:

> I'm trying to use the Graphics2D api to draw some simple shapes
> on a class that I extended from JPanel. I'm want to set the
> background in my object, but I have been unable to get it to
> work.  I've tried using super.setBackground(Color.white) from
> within my class.
> 
> I have overloaded the paintComponent() method in my class and
> I don't know if that has anything to do with it.  I know that
> when I comment out the paintComponent() method it paints the
> background correctly.  However, it's my understanding that I
> have to overload the paintComponent() method to draw my shapes
> with the Graphics2D api.

Did you call the superclass paintComponent() method in your method?
For example:

    public void paintComponent( Graphics g ) {
        super.paintComponent( g );
        :
        //  Now draw some simple shapes
    }

-- 
John P. McGrath
<JPMcGrath@fast.net>
<jpm@nscs.fast.net>
Technical Details
Message-ID: <MPG.134a176e6ac1641c989832@forums.borland.com>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <38DF8772.DE6AFEF6@softrealityinc.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 111d45,e8ac0b4dbbc13ca5
X-Google-Attributes: gid111d45,public
From: John P. McGrath <JPMcGrath@fast.net>
Subject: Re: Set background after extending JPanel?
Date: 2000/03/28
Message-ID: <MPG.134a176e6ac1641c989832@forums.borland.com>
X-Deja-AN: 603290303
References: <38DF8772.DE6AFEF6@softrealityinc.com>
Organization: Another Netscape Collabra Server User
Newsgroups: borland.public.jbuilder.java.swing