Does getContentPane().add() mean the same as add() ?
public class TestFrame extends JFrame{
public TestFrame() {
JLabel label = new JLabel("jo");
getContentPane().add(label);
add(label);
}
}
Does getContentPane().add() mean the same as add() ?
Yes, since 1.5+.
Mostly. To make things "easier", addImpl
was changed to forward to the content pane, but in uncommon corner cases it doesn't (for instance, the content pane needs to be added somehow).
This method is overridden to conditionally forward calls to the contentPane.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With