Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Java (http://www.velocityreviews.com/forums/f30-java.html)
-   -   can't stop JPanel paint (http://www.velocityreviews.com/forums/t751445-cant-stop-jpanel-paint.html)

Peter Cheung 07-14-2011 11:43 AM

can't stop JPanel paint
 
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 (cmk128@hotmail.com)

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) {

}
}

supercalifragilisticexpialadiamaticonormalizeringelimatisticantations 07-14-2011 12:37 PM

Re: can't stop JPanel paint
 
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.

Roedy Green 07-26-2011 01:30 PM

Re: can't stop JPanel paint
 
On Thu, 14 Jul 2011 04:43:04 -0700 (PDT), Peter Cheung
<cmk128@gmail.com> 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.


All times are GMT. The time now is 10:29 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.