控件都应该有一个setVisible(boolean b)的方法,可设制它可见不见,不知道这是不是你要要的东西?
再不然你可以定义类变量,在new 你的applet时传参进去,用这个类量来控制显示。不知道我理解你的意思没,抱歉。

解决方案 »

  1.   

    不是很清楚你的问题,Applet的布局为FlowLayout,JApplet的布局为BorderLayout,
    你可以自定义继承label和checkbox等的控件,就可自己再给它们一个标志了,根据那个标志属性来决定要不要显示
    validate()是强制重新布局。问一下,VB中你常用类模块来写程序吗?
      

  2.   

    类模块不常用的,一般的类(大部分封装了)以及函数都是日本的公司发过来,习惯和这面不同,偶现在是用vb做成exe文件(类似cgi),里面用到了javaapplet!
      

  3.   

    还不是很清楚你的问题Applet和JApplet的默认布局分别是FlowLayout和BorderLayout提示一下,你可以自定义继承自Label或CheckBox等的控件来放置一个是否显示的标志属性
    class CustomLabel extends Label{
        public boolean flag=false;//标识
    }Label l1=new CustomLabel();
    l1.setText("文本");强制重新布局用validate();不过也是要在invalidate的情况下才会起作用借问一下,VB中常用类模块来写程序吗
      

  4.   

    不常用的,一般的类模块都不是简简单单的,现在一般的做法是要么你就做类模块
    要么就是用现成的,又要自己编,又要自己用这样子太少了,而且大程序的类模块要求很高!我是用GridBagLayout布局的,和上面的一样吗?
    上面的flag 什么时候传呀?
      

  5.   

    代码也帮你写了一点,可super.xxx调超类的方法。其他方面你脸皮厚我不嫌不过我就嫌你是厚着脸皮帮鬼子做事
      

  6.   


    无语,现在生存难呀,中国人的公司当初不要我,嫌我没经验,我只好到日本公司了,没办法呀。
    。。不过你的代码也太简单了,呵呵。随你喜欢吧,你帮到这样,我已经很感谢了,最起码我知道这个问题javaapplet可以实现~~~~
      

  7.   

    java 文件:
             
    import java.awt.*;
    import java.util.*;
          import java.applet.Applet;
         
          public class QTest extends Applet {

       String pid;
              protected void makecheckbox(String name, GridBagLayout gridbag,GridBagConstraints c,String pid) {
                  String str=new String("10");

    Checkbox checkbox = new Checkbox(name);
                  gridbag.setConstraints(checkbox, c);
    if (str==pid)
    {checkbox.setVisible(true); }
    else 
    {checkbox.setVisible(false);}
                  add(checkbox);
              }
    protected void makelabel(String name, GridBagLayout gridbag,GridBagConstraints c,String pid) {
    String str=new String("10");

                  Label label= new Label(name);
                  gridbag.setConstraints(label, c);
    if (str==pid)
    {label.setVisible(true);}
    else 
    {label.setVisible(false);}
                  add(label);
              }
    protected void maketext(String name, GridBagLayout gridbag,GridBagConstraints c,String pid) {
    String str=new String("20");
    TextArea text = new TextArea(name,3,60);
                  if (str==pid)
    {text.setVisible(true);}
    else
    {text.setVisible(false);}
    gridbag.setConstraints(text, c);
                  add(text);
              }
         
              public void init() {
    pid=getParameter("pid");
    setBackground(Color.green);
    draw();
    }
    public void draw() {

    GridBagLayout gridbag = new GridBagLayout();
                  GridBagConstraints c = new GridBagConstraints();
                  setFont(new Font("Helvetica", Font.PLAIN, 14));
                  setLayout(gridbag);
    c.gridwidth = GridBagConstraints.REMAINDER; 
    c.gridx=0;              c.fill = GridBagConstraints.BOTH;
    makelabel("Label1", gridbag, c,pid);

    makecheckbox("Checkbox1", gridbag, c,pid);

    makecheckbox("Checkbox2", gridbag, c,pid);

                  makecheckbox("Checkbox3", gridbag, c,pid);

    makelabel("Label2", gridbag, c,pid);

    maketext("", gridbag, c,pid);

    }
    }
    HTML 文件:<html>
    <body>
    <applet code=QTest.class width=90% height=90%>
    <param name=pid value="10" >
    </applet>
    </body>
    </html>可是没有记录显示?为什么? 先谢谢大家了!