| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 825 人关注过本帖
标题:请教高手,高手进!!!!!
取消只看楼主 加入收藏
wsjmt2334031
Rank: 1
等 级:新手上路
帖 子:35
专家分:0
注 册:2004-11-17
收藏
 问题点数:0 回复次数:3 
请教高手,高手进!!!!!

该程序的作用是,点击按钮,把 textfield 里的内容的英文部分添加到choice的项目,如果选择下拉菜单中的英文单词,把对应的中文在标签上 (lab2) 显示出来. 在textfield中输入的英文和中文,之间用#间隔!!
望指教!!!!!!!!!!!!!


12,13行有错误,我个人认为是创建字符串对象数组的时候,出错,可是就找不出来,望指教!!!!!!!!!!!!!


import java.awt.*;
import java.awt.event.*;
public class dictionary extends Frame implements ActionListener,ItemListener,TextListener
{
static dictionary frm=new dictionary();
static Label lab1=new Label("中文释义为:");
static Label lab2=new Label();
static TextField tex=new TextField();
static Button btn=new Button("添加");
static Choice cho=new Choice();
String Eng[];String Chi[];
Eng=new String[15];
Chi=new String[15];


public static void main(String args[])
{
frm.setLayout(null);
frm.setTitle("应用与维护");
frm.setBounds(100,100,700,700);
lab1.setBounds(100,100,300,100);
lab2.setBounds(100,250,400,100);
tex.setBounds(100,400,600,100);
btn.setBounds(100,550,100,100);
cho.setBounds(250,550,350,100);
cho.add("英文单词");
tex.addTextListener(frm);
btn.addActionListener(frm);
cho.addItemListener(frm);
frm.add(lab1);
frm.add(lab2);
frm.add(tex);
frm.add(btn);
frm.add(cho);
frm.setViseble(true);
}
public void textValueChanged(TextEvent e)
{
for(int a=1;a<=15;a++)
System.out.println(a+"次处理");
}
public void actionPerformed(ActionEvent e)
{
String str;
str=tex.getText();
inti=1;
char c=str.charAt(i);
while(c!='#')
{
i++;
c=str.charAt(i);
}
int j=0;
while(j<15)
{
Eng[j]=new String();
Chi[j]=new String();
Eng[j]=str.substring(0,i);
CHi[j]=set.substring(i);
if(cho.getItemCount()<=15)
cho.add(Eng[j]);
j++;
}
tex.setText(" ");
}
public void itemStateChanged(ItemEvent e)
{
int dex;
dex=cho.getSelectedIndex();
if(dex>=1)
lab2.setText(Chi[dex-1]);
}
}

搜索更多相关主题的帖子: choice public dictionary 英文 
2005-12-20 09:12
wsjmt2334031
Rank: 1
等 级:新手上路
帖 子:35
专家分:0
注 册:2004-11-17
收藏
得分:0 
谢谢斑竹!!
不过,我运行的时候还是有很多错啊 !!!
2005-12-21 12:25
wsjmt2334031
Rank: 1
等 级:新手上路
帖 子:35
专家分:0
注 册:2004-11-17
收藏
得分:0 
好像运行时候有错误啊,runtime 的错误啊,过个了编译了啊,斑竹!!!
不过,我不知道怎么改,因为swing 类我还没学啊,呵呵!!!!
2005-12-31 10:37
wsjmt2334031
Rank: 1
等 级:新手上路
帖 子:35
专家分:0
注 册:2004-11-17
收藏
得分:0 
我错了,我的jdk 是,1.4怪不的啊,谢谢斑竹!!!
2005-12-31 10:38
快速回复:请教高手,高手进!!!!!
数据加载中...
 
   



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

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