当前位置: 代码迷 >> Java相关 >> 大家看看是怎么回事?
  详细解决方案

大家看看是怎么回事?

热度:380   发布时间:2012-04-03 18:00:26.0
大家看看是怎么回事?
程序:
//
import java.awt.*;
import java.awt.event.*;
//import java.swing.*;
import java.net.*;
import java.io.*;


public class LoginDemol6 extends Frame implements ActionListener , ItemListener
{
    Label ly = new Label("请输入你的个人信息,账号和密码,单击确定");
    Label lLogin = new Label("账号:");
    Label lKey = new Label("密码:");
    Label lName = new Label("姓名:");
    Label lSex = new Label("性别:");
    Label lBd = new Label("生日:");
    Label lHobby = new Label("爱好:");
    TextField tLogin  = new TextField("",6);
    TextField tKey = new TextField("",6);
   
    TextField tName = new TextField("",6);
    CheckboxGroup nannv = new CheckboxGroup();
    Checkbox nan = new Checkbox("男",nannv,true);
    Checkbox nv = new Checkbox("女",nannv,false);
     
    Choice cn = new Choice();
    Choice cy = new Choice();
    Choice cr = new Choice();

    Checkbox c1 = new Checkbox("电影",false);
    Checkbox c2 = new Checkbox("阅读",false);
    Checkbox c3 = new Checkbox("网络",false);
    Checkbox c4 = new Checkbox("编程",false);
    Checkbox c5 = new Checkbox("艺术",false);
    Checkbox c6 = new Checkbox("旅游",false);
    Checkbox c7 = new Checkbox("游戏",false);
    Checkbox c8 = new Checkbox("其他",false);
    TextArea ta = new TextArea("",3,30);
    Button qd = new Button("确定");
    Button tc = new Button("退出");
    String Sex = "",Year = "",Month = "",Day= "";
    String Film = "",Reading = "",Network = "",Program = "",Art = "",Tourism = "",Game = "",Others = "";
    String strKey = "";
    Boolean flag = true;
    public LoginDemol6()
    {
        setTitle("用户个人信息");
        setLayout(new FlowLayout());
        add(ly);
        add(lLogin);
        add(tLogin);
        add(lKey);
        tKey.setEchoChar('*');
        add(tKey);
        add(lName);
        add(tName);
        add(lSex);
        nan.addItemListener(this);
        nv.addItemListener(this);
        add(nan);
        add(nv);
        add(lBd);
        String a[]=new String[5];
        int i, s = 0;
        for (i=1990;s<a.length;i++ )
        {
            a[s] = new String();
            a[s].append(i+"年");
            cn.add(a[s]);
        }
        cy.add("11月");
        cy.add("12月");
        cr.add("11日");
        cr.add("12日");
        cn.addItemListener(this);
        cy.addItemListener(this);
        cr.addItemListener(this);
        add(cn);
        add(cy);
        add(cr);
        add(lHobby);
        c1.addItemListener(this);
        c2.addItemListener(this);
        c3.addItemListener(this);
        c4.addItemListener(this);
        c5.addItemListener(this);
        c6.addItemListener(this);
        c7.addItemListener(this);
        c8.addItemListener(this);
        add(c1);
        add(c2);
        add(c3);
        add(c4);
        add(new Label(" "));
        add(new Label(" "));
        add(c5);
        add(c6);
        add(c7);
        add(c8);
        qd.addActionListener(this);
        tc.addActionListener(this);
        add(ta);
        add(qd);
        add(tc);
        setSize(260,320);
        setVisible(true);
        addWindowListener(new WindowAdapter()
                          {
                           public void windowClosing(WindowEvent e)
                              {
                               System.exit(0);
                              }
                          });
    }
    public void actionPerformed(ActionEvent ae)
    {
        ta.setText("");
        if (ae.getSource() == qd)
        {
            
            if (flag == true)
            {
                flag = false;
                ta.append("姓名:"+tName.getText()+"\n");
                ta.append("性别:"+Sex+"\n");
                ta.append("生日:"+Year+Month+Day+"\n");
                ta.append("爱好:"+Film+Reading+Network+Program+Art+Tourism+Game+Others+"\n");
                strKey = tKey.getText();
                tKey.setText("");
                ly.setText("请再次输入密码,然后单击确定");
            }
            else
            {
                if (tKey.getText().equals(strKey))
                {
                    ly.setText("注册成功!");
                }
                else
                {
                    ly.setText("密码与上次不符,请再次输入密码!");
                }
            }
        }
        else
        {
            System.exit(0);
        }
    }
    public void itemStateChanged(ItemEvent e)
    {
        if (nan.getState())
        {
            Sex = nan.getLabel();
        }
        if (nv.getState())
        {
            Sex = nv.getLabel();
        }
        if (e.getItemSelectable() == cn)
        {
            Year = cn.getSelectedItem();
        }
        if (e.getItemSelectable() == cy)
        {
            Month = cy.getSelectedItem();
        }
        if (e.getItemSelectable() == cr)
        {
            Day = cr.getSelectedItem();
        }
        if (c1.getState())
        {
            Film = c1.getLabel();
        }
        if (c2.getState())
        {
            Reading = c2.getLabel();
        }
        if (c3.getState())
        {
            Network = c3.getLabel();
        }
        if (c4.getState())
        {
            Program = c4.getLabel();
        }
        if (c5.getState())
        {
            Art = c5.getLabel();
        }
        if (c6.getState())
        {
            Tourism = c6.getLabel();
        }
        if (c7.getState())
        {
            Game = c7.getLabel();
        }
        if (c8.getState())
        {
            Others = c8.getLabel();
        }
    }
   
    public static void main(String args[])
    {
        new LoginDemol6();
    }
}
编译时出现如下错误:
E:\java>javac LoginDemol6.java
LoginDemol6.java:68: 找不到符号
符号: 方法 append(java.lang.String)
位置: 类 java.lang.String
            a[s].append(i+"年");
                ^
1 错误
搜索更多相关的解决方案: 密码  生日  public  import  个人信息  

----------------解决方案--------------------------------------------------------
String类是没有这个方法(append)的,append它在StringBuffer类中。建议楼主多看帮助手册。
----------------解决方案--------------------------------------------------------
  相关解决方案