Topic: panel求助

  Print this page

1.panel求助 Copy to clipboard
Posted by: SWandCC
Posted on: 2006-04-15 14:57

//容器的嵌套
import java.awt.*;
import java.applet.Applet;
public static class PanelExample extends Applet
{
public void init()
{
Panel p=new Panel();
p.setBackground(Color.yellow);
p.add(new Label("hello"));
MyPanel mp=new MyPanelCamera;
mp.setBackground(Color.red);
add(mp);
}

public class MyPanel extends Panel //这个方法是在tp里嵌套一个mpc吗?
{
Panel tp;
public MyPanel(Panel mpc)
{
tp=mpc;             //这里为什么要让tp=mpc?
add(mpc);
}
}
}

小弟刚学JAVA,希望大家能帮帮我,谢谢了

2.Re:panel求助 [Re: SWandCC] Copy to clipboard
Posted by: scwfeng
Posted on: 2006-04-15 18:29

我也是初学者,我认为其目的是把mpc这个对象的指引传给tp

3.Re:panel求助 [Re: SWandCC] Copy to clipboard
Posted by: JavaandC
Posted on: 2006-04-16 09:26

Panel tp; 和 tp=mpc; 这两句代码是废话,可以不要。

4.Re:panel求助 [Re: SWandCC] Copy to clipboard
Posted by: SWandCC
Posted on: 2006-04-16 20:51

感谢!我一直在想这两句有什么用.......为什么不能直接add(mpc),终于找到答案了啊,哈哈


   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