| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 539 人关注过本帖
标题:能帮我看看下面这个程序的问题吗,有点长,帮个忙啊,谢谢啊
取消只看楼主 加入收藏
huxiangwenhu
Rank: 4
等 级:业余侠客
威 望:1
帖 子:191
专家分:262
注 册:2010-6-1
结帖率:90.91%
收藏
已结贴  问题点数:30 回复次数:0 
能帮我看看下面这个程序的问题吗,有点长,帮个忙啊,谢谢啊
//下面是一个注册小示例
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.EventListener;
import java.awt.event.ItemListener;
import *;
public class huxiang extends Frame implements ActionListener{
    Panel panel1=new Panel();
    Panel panel2=new Panel();
    Panel panel3=new Panel();
    Panel panel4=new Panel();
    Panel panel5=new Panel();
    Panel panel6=new Panel();
    Panel panel7=new Panel();
    Panel panel8=new Panel();
    Panel panel9=new Panel();
    Label label=new Label("QQ注册窗体");
    Label label1=new Label("账 号");
    Label label2=new Label("密 码");
    Label label3=new Label("昵 称");
    Label label4=new Label("性 别");
    Label label5=new Label("EMAIL:");
    Label label6=new Label("地 址");
    Label label7=new Label("           ");
    Choice choice1=new Choice();
    TextField text1=new TextField(12);
    TextField text2=new TextField(12);
    TextField text3=new TextField(12);
    TextField text4=new TextField(12);
    TextField text5=new TextField(12);
    Button button1=new Button("确定");
    Button button2=new Button("取消");
    public huxiang(){
        this.setTitle("QQ注册");
        this.setResizable(false);
        this.setLayout(new BorderLayout());
        button1.addActionListener(this);
        button2.addActionListener(this);
        choice1.addItem("男");
        choice1.addItem("女");
        choice1.select(1);
        panel8.add(label);
        panel1.add(label1);
        panel1.add(text1);
        panel2.add(label2);
        panel3.add(label3);
        panel4.add(label4);
        panel5.add(label5);
        panel6.add(label6);
        panel2.add(text2);
        panel3.add(text3);
        panel4.add(choice1);
        panel5.add(text4);
        panel6.add(text5);
        panel7.add(button1);
        panel7.add(button2);
        panel9.setLayout(new GridLayout(7,1));
        panel9.add(panel1);
        panel9.add(panel2);
        panel9.add(panel3);
        panel9.add(panel4);
        panel9.add(panel5);
        panel9.add(panel6);
        panel9.add(panel7);
        this.add(panel8,BorderLayout.NORTH);
        this.add(panel9,BorderLayout.CENTER);
        this.setVisible(true);
        this.setSize(200,320);
        this.show();
        }
    public static void main(String args[]){
        new huxiang();
        }
    public void actionPerformed(ActionEvent e){
        if(e.getSource()==button1){
            String s1=text1.getText();
            String s2=text2.getText();
            String s3=text3.getText();
            String s5=text4.getText();
            String s6=text5.getText();
            String s4=choice.getSelectItem();
            if(s1.equals("")||s2.equals("")||s3.equals("")||s5.equals("")||s6.equals("")){
                System.out.println("注册信息失败:请填写完整的信息...");
                }
            else{
                String regMsg="regMsg:"+s1+"_"+s2+"_"+s3+"_"+s4+"_"+s5+"_"+s6+"_";
                try{
                    FileWriter output=new FileWriter("reginfor.txt",true);
                    PrintWriter pw=new PrintWriter(output,true);
                    pw.println(reMsg);
                    pw.flush();
                    System.out.println("注册成功...\n注册信息为:"+regMsg);
                    }catch(Exception e1){
                        e1.printStackTrace();
                        }
                    }
                }
        else(e.getSource()==button2){                  //编译器提示这个地方错误 not a statement
                System.out.println("退出程序...");
                System.exit(0);
            }
        }
    }
    //大侠们帮我看看吧,我实在是找不出问题了,谢谢了
搜索更多相关主题的帖子: public import 
2010-07-28 21:29
快速回复:能帮我看看下面这个程序的问题吗,有点长,帮个忙啊,谢谢啊
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.049097 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved