Article View: borland.public.jbuilder.java.swing
Article #12932Re: Problem with drawing in JPanel
From: Vladimir Olenin
Date: Thu, 22 Oct 1998 00:00
Date: Thu, 22 Oct 1998 00:00
70 lines
2780 bytes
2780 bytes
This is a multi-part message in MIME format.
--------------915F41E32AAA8FC7207270A1
Content-Type: text/plain; charset=koi8-r
Content-Transfer-Encoding: 7bit
Anne, just a wild guess: try to set background in paintComponent method.
I think that must work, though understand it's not the solution of yr
problem. It might occur as well that the original paintComponent method
of JPanel called some other repaint function to redraw background. So,
try to call JPanel's paintComponent method from yr overridden one. But,
again, it just MIGHT help.
Vladimir
> Anne JANSSENS wrote:
>
> Hi, here is my problem :
> I want to draw in a JTable, where I have already put a button.
> I rewrite the method paintComponent, but the color of the background
> become every times grey instead of any color, why ?
>
> Thanks for any suggestions, Anne
>
> Here is the code of my program :
>
> import com.sun.java.swing.*;
> import java.awt.*;
> public class un_panel extends JPanel
> {
>
> public un_panel()
> { this.setLayout(new BorderLayout());
> this.setBackground(Color.pink); // i want the
> panel to be in pink color
> JButton un_bouton=new JButton("hello");
> this.add(un_bouton,"North");
> }
>
> public void paintComponent(Graphics g)
> { g.setColor(Color.black);
> g.drawString("hello", 50,50);
>
> }
> }
--
>-------<===========>-------<
Join in Java community now!
http://www.geocities.com/SiliconValley/Heights/9815
(NB: the page is under construction now)
>-------<===========>-------<
--------------915F41E32AAA8FC7207270A1
Content-Type: text/x-vcard; charset=koi8-r;
name="keenonjava.vcf"
Content-Transfer-Encoding: 7bit
Content-Description: Card for Vladimir Olenin
Content-Disposition: attachment;
filename="keenonjava.vcf"
begin:vcard
n:Vladimir;Olenin
x-mozilla-html:FALSE
adr:version:2.1
version:2.1
email;internet:keenonjava@collegemail.com
note:Java programmer. Open for project development offers. See my home page at: http://www.geocities.com/SiliconValley/Heights/9815/
end:vcard
--------------915F41E32AAA8FC7207270A1--
Technical Details
Message-ID:
<362E619B.C8126529@collegemail.com>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailReferences:
<70kkt2$hfp6@forums.borland.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 111d45,74df4fde9fb2834 X-Google-Attributes: gid111d45,public From: Vladimir Olenin <keenonjava@collegemail.com> Subject: Re: Problem with drawing in JPanel Date: 1998/10/22 Message-ID: <362E619B.C8126529@collegemail.com> X-Deja-AN: 403700056 References: <70kkt2$hfp6@forums.borland.com> X-Accept-Language: en,ru Content-Type: multipart/mixed; boundary="------------915F41E32AAA8FC7207270A1" Organization: Another Netscape Collabra Server User Mime-Version: 1.0 Newsgroups: borland.public.jbuilder.java.swing