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

这 个程序哪儿有错啊,我就是找不到啊,望不吝指教!!!!!!!!

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.setVisible(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();
int i=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]=str.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]);
}
}

搜索更多相关主题的帖子: 斑竹 
2005-12-20 10:09
cll19820814
Rank: 2
等 级:新手上路
威 望:3
帖 子:328
专家分:0
注 册:2005-11-30
收藏
得分:0 
要有注释,要有简单的说明。
格式要规范,大小写要注意。
一个光秃秃的程序就拿上来了,这样不好吧~

懵懵懂懂,看千遍而不会;设身处地,试一下就成功!
2005-12-20 11:14
bagger
Rank: 7Rank: 7Rank: 7
等 级:贵宾
威 望:33
帖 子:891
专家分:0
注 册:2005-8-16
收藏
得分:0 

你的程序问题太多了,你主要想解决哪方面的问题?


【三元毕业设计论文】
三元论文真的只有三元钱
客服QQ:742670649
http://shop35094218./
2005-12-20 12:53
cll19820814
Rank: 2
等 级:新手上路
威 望:3
帖 子:328
专家分:0
注 册:2005-11-30
收藏
得分:0 

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

class Dictionary extends JFrame implements ActionListener,ItemListener,TextListener
{
private Label lab1=new Label("中文释义为:");
private Label lab2=new Label();
private TextField tex=new TextField();
private Button btn=new Button("添加");
private Choice cho=new Choice();
private String[] eng = new String[15];
private String[] chi = new String[15];
private JPanel p = new JPanel();
public Dictionary()
{ getContentPane().add(p);
p.setLayout(null);
setTitle("应用与维护");
setSize(800, 800);
tex.setBounds(100,400,600,100);
btn.setBounds(100,550,100,100);
cho.setBounds(250,550,350,100);
cho.add("英文单词");
tex.addTextListener(this);
btn.addActionListener(this);
cho.addItemListener(this);
p.add(lab1);
p.add(lab2);
p.add(tex);
p.add(btn);
p.add(cho);
addWindowListener(new WindowAdapter()
{ public void windowClosing(WindowEvent evt)
{ System.exit(0); }
});
}

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();
int i = 1,j = 0;
char c=str.charAt(i);
while(c!='#')
{ i++;
}
eng[j] = str.substring(0,i);
chi[j] = str.substring(i);
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]);
}
}

public class DictionaryTest
{ public static void main(String args[])
{ Dictionary frm=new Dictionary();
frm.setVisible(true);

}
}
他的意思好象是在文本框中输入一个字符串 格式:“英#汉”,在选择框中选中哪个英文,标签就显示出它的译文。我改了一下,输入字符串后会死机.......哪个老大帮忙看看啊?


懵懵懂懂,看千遍而不会;设身处地,试一下就成功!
2005-12-20 13:01
wsjmt2334031
Rank: 1
等 级:新手上路
帖 子:35
专家分:0
注 册:2004-11-17
收藏
得分:0 
就那意思,为什么不成功呢?
2005-12-20 15:24
快速回复:请教斑竹!!!!!!
数据加载中...
 
   



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

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