Topic: 不明白 contentPane = (JPanel) this.getContentPane()

  Print this page

1.不明白 contentPane = (JPanel) this.getContentPane() Copy to clipboard
Posted by: zsh220824
Posted on: 2008-01-22 17:19

contentPane = (JPanel) this.getContentPane()
这个句子什么意思?其中(JPanel)格式对吗?谢谢

2.Re:不明白 contentPane = (JPanel) this.getContentPane() [Re: zsh220824] Copy to clipboard
Posted by: tzutolin
Posted on: 2008-01-24 09:11

Hi zsh220824,

"this.getContentPane" returns a type of Container which is a parent class of JComponent as well as JPanel.

However, I don't see anything wrong syntatically here with your statement since you can do a strong type cast in Java (Please correct me if I am wrong).

This statment is basically get the contentPane from your JFrame and cast it to a JPanel and then reassign to a local variable which is named as contentPane.

Best Regards,
David


   Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent
Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1
客服电话 18559299278    客服信箱 714923@qq.com    客服QQ 714923