Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > can't stop JPanel paint

Reply
Thread Tools

can't stop JPanel paint

 
 
Peter Cheung
Guest
Posts: n/a
 
      07-14-2011
Hi
I have overrider all the paintXX method and did nothing in there. But why I still able to see the component on top of the JPanel?

thanks
from Peter ((E-Mail Removed))

import java.awt.CardLayout;

public class Carousel extends JPanel {
public Carousel() {
setLayout(new CardLayout(0, 0));
b.setSize(100, 100);
}

public Component add(Component c) {
add(c, "");
return c;
}

public void paint(Graphics g) {
}

public void paintComponents(Graphics g) {

}

public void paintChildren(Graphics g) {
System.out.println("ss");
}

public void paintImmediately(int x, int y, int w, int h) {
}

public void paintImmediately(Rectangle r) {
}

public void repaint(long tm, int x, int y, int width, int height) {

}
}
 
Reply With Quote
 
 
 
 
supercalifragilisticexpialadiamaticonormalizeringelimatisticantations
Guest
Posts: n/a
 
      07-14-2011
On 14/07/2011 7:43 AM, Peter Cheung wrote:
> Hi
> I have overrider all the paintXX method and did nothing in there. But why I still able to see the component on top of the JPanel?


A component in a container such as a panel paints itself separately, not
as part of the panel's paint. If the area is obscured and then
uncovered, a repaint event is sent to the panel first, then to its
children. Even if the panel itself ignores the event the children
generally won't.
 
Reply With Quote
 
 
 
 
Roedy Green
Guest
Posts: n/a
 
      07-26-2011
On Thu, 14 Jul 2011 04:43:04 -0700 (PDT), Peter Cheung
<(E-Mail Removed)> wrote, quoted or indirectly quoted someone who said
:

>Hi
> I have overrider all the paintXX method and did nothing in there. But why I still able to see the component on top of the JPanel?


you would gave to block the paint methods of all the children which
might be invoked independently of the JPanel container if their values
changed.

I trust you are just experimenting. The proper way to hide things is
with setVisible( false ).
--
Roedy Green Canadian Mind Products
http://mindprod.com
Most of computer code is for telling the computer
what do if some very particular thing goes wrong.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
JPanel inside JPanel inside JFrame t1m1976 Java 1 11-07-2010 09:47 PM
[JPanel] Drop Down JPanel Raphael Jolivet Java 1 07-18-2008 12:30 AM
Unable to paint (using paint() in JPanel) inside mouse listeners eshedz@gmail.com Java 4 10-23-2005 09:13 PM
paint my jpanel Rajesh.Rapaka Java 1 04-22-2005 08:31 AM
Add a JPanel to a JPanel... Andreas Beresko Java 6 07-16-2004 12:10 AM



Advertisments