can't stop JPanel paint

P

Peter Cheung

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 ([email protected])

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

}
}
 
S

supercalifragilisticexpialadiamaticonormalizeringe

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.
 
R

Roedy Green

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

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top