| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1035 人关注过本帖
标题:简单通迅录不能用?
取消只看楼主 加入收藏
yqiong
Rank: 1
等 级:新手上路
帖 子:315
专家分:0
注 册:2007-7-4
结帖率:83.33%
收藏
 问题点数:0 回复次数:2 
简单通迅录不能用?
用eclipse开发的程序,运行时没错误,但点击按钮时就出错了!请各位帮帮忙错在哪了?为什么错了?谢谢(代码直接复制就可运行)
import java.awt.Frame;
import javax.swing.*;
import java.awt.event.*;
import java.awt.*;
import java.lang.*;

public class userframe extends JFrame implements ActionListener, ItemListener{
    int nunber=1;
    JComboBox jcb_city,jcb_pr;
    JTextArea ta;
    JTextField tx_number,tx_name;
    ButtonGroup bg;
    JRadioButton rb1,rb2;
    
    
    public userframe(){
        super("输入用户信息");
        this.setSize(400,360);
        this.setLocation(100,50);
        this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        
        this.setLayout(new GridLayout(1,2));
        
        
        ta=new JTextArea();
        ta.setEditable(false);
        this.add(ta);
        
        Panel pan=new Panel();
        pan.setLayout(new GridLayout(6,1));
        this.add(pan);
       
        tx_number=new JTextField("1");
        tx_number.setEditable(false);
        pan.add(tx_number);
       
        tx_name=new JTextField("姓名");
        pan.add(tx_name);
       
        JPanel panmi=new JPanel();
        panmi.setLayout(new GridLayout(1,2));
        pan.add(panmi);
        bg=new ButtonGroup();
        JRadioButton rb1=new JRadioButton("男",true);
        bg.add(rb1);
        panmi.add(rb1);
       
        JRadioButton rb2=new JRadioButton("女",false);
        bg.add(rb2);
        panmi.add(rb2);
       
        Object province[]={"浙江","江苏","湖南"};
        JComboBox jcb_pr=new JComboBox(province);
        jcb_pr.addItemListener(this);
        pan.add(jcb_pr);
       
        Object city[]={"宁波","杭州","温州"};
        JComboBox jcb_city=new JComboBox(city);
        pan.add(jcb_city);
       
        JButton jb_add=new JButton("添加");
        jb_add.addActionListener(this);
        pan.add(jb_add);
       
        this.setVisible(true);
        }

    public static void main(String[] args) {
    new userframe();
    }

    public void actionPerformed(ActionEvent e) {
        String str="";
        str+=tx_number.getText()+","+tx_name.getText()+",";
        if(rb1.isSelected())
            str+=rb1.getText()+",";
        else
            str+=rb2.getText();
        str+=jcb_pr.getSelectedItem();
        str+=jcb_city.getSelectedItem();
        System.out.println();
        this.nunber++;
        this.tx_number.setText(Integer.toString(this.nunber));
        this.tx_name.setText("姓名");
    }



    public void itemStateChanged(ItemEvent e) {
    //    if(e.getItem()=="浙江")//        
            if(jcb_pr.getSelectedIndex()==0)
        {
            jcb_city.removeAllItems();
            jcb_city.addItem("杭州市");
            jcb_city.addItem("宁波市");
            jcb_city.addItem("温州市");
        }
    //    if(e.getItem()=="江苏");//
        if(jcb_pr.getSelectedIndex()==1)
        {
            jcb_city.removeAllItems();
            jcb_city.addItem("南京市");
            jcb_city.addItem("镇江市");
            jcb_city.addItem("扬州市");
        }
        //if(e.getItem()=="湖南");//
        if(jcb_pr.getSelectedIndex()==2)
        {
            jcb_city.removeAllItems();
            jcb_city.addItem("长沙市");
            jcb_city.addItem("湘漂市");
            jcb_city.addItem("株州市");
        }
    }

}
搜索更多相关主题的帖子: 通迅录 运行出错 
2008-11-02 22:28
yqiong
Rank: 1
等 级:新手上路
帖 子:315
专家分:0
注 册:2007-7-4
收藏
得分:0 

但是这样修改了以后还是不能用呀!表省份的组合框不能选择,添加按钮也没有反应呢!
2008-11-05 21:08
yqiong
Rank: 1
等 级:新手上路
帖 子:315
专家分:0
注 册:2007-7-4
收藏
得分:0 
回复 4# 的帖子
恩,知道了,谢谢哦
2008-11-11 15:44
快速回复:简单通迅录不能用?
数据加载中...
 
   



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

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