Topic: contentPane = (JPanel) this.getContentPane() |
Print this page |
1.contentPane = (JPanel) this.getContentPane() | Copy to clipboard |
Posted by: zsh220824 Posted on: 2008-01-23 08:01 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:09 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 |
3.Re:contentPane = (JPanel) this.getContentPane() [Re: zsh220824] | Copy to clipboard |
Posted by: zsh220824 Posted on: 2008-01-24 17:24 Mr.David,thank you for the reply.now I Learn SOME from you . I think that (JPanel) means the statement returns a JPanel,not a JComponent. Is it right? |
4.Re:contentPane = (JPanel) this.getContentPane() [Re: zsh220824] | Copy to clipboard |
Posted by: tzutolin Posted on: 2008-01-24 17:45 Hi zsh220824, The syntax () can be used as a type casting operator. So you can say that once we get the returned content pane and then we use (JPanel) to cast it to a JPanel. 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 |