当前位置: 代码迷 >> Java相关 >> 与大家分享,同时感谢几位高手的指点!!!
  详细解决方案

与大家分享,同时感谢几位高手的指点!!!

热度:150   发布时间:2005-12-31 10:13:00.0
与大家分享,同时感谢几位高手的指点!!!

感谢大家前几天的不吝指教,小弟,前几天的程序的错误,已经完全改正了,并且程序也改了不少地方,删除了个函数!!!传上来和大家一起分享了!!
哈哈,不要发笑啊!!!!!哦,对了,程序中的 古风猫 是我的QQ名字,呵呵,!!!别见怪!!!
import java.awt.*;
import java.awt.event.*;

public class dictionary extends Frame implements ActionListener,ItemListener
{
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[]=new String[15];String Chi[]=new String[15];
int j=0;
int a=0;

public static void main(String args[])
{
frm.setLayout(null);
frm.setTitle("o3级计算机应用与维护");
frm.setBounds(50,10,700,700);
lab1.setBounds(100,100,300,100);
lab2.setBounds(100,250,400,100);
tex.setBounds(100,400,500,100);
btn.setBounds(100,550,100,100);
cho.setBounds(250,550,300,300);
cho.add("英文单词");
tex.addActionListener(frm); // tex.addTextListener(frm);
btn.addActionListener(frm);
cho.addItemListener(frm);
frm.add(lab1);
frm.add(lab2);
frm.add(tex);
frm.add(btn);
frm.add(cho);
Font fnt=new Font("Serief",Font.BOLD,20);
lab1.setAlignment(Label.CENTER);
lab1.setFont(fnt);
lab2.setFont(fnt);
lab2.setAlignment(Label.LEFT);
tex.setFont(fnt);
btn.setFont(fnt);
lab1.setBackground(Color.orange);
lab2.setBackground(Color.yellow);
tex.setBackground(Color.blue);
btn.setBackground(Color.green);
cho.setBackground(Color.red);
lab1.setForeground(Color.red);
lab2.setForeground(Color.blue);
tex.setForeground(Color.yellow);
btn.setForeground(Color.pink);
cho.setForeground(Color.blue);

frm.setVisible(true);
}
public void actionPerformed(ActionEvent e)
{
if(e.getSource()==tex)
{
//int a=0;
a++;
System.out.println(a+"次输入");
System.out.println("古风猫写");
if(a>15)
System.out.println("太多了,不能写到下拉列表里了");

}
else if(e.getSource()==btn)
{
String str;
char c;
int i=1;
str=tex.getText();
c=str.charAt(i);
while(c!='#')
{
i++;
c=str.charAt(i);
}
//
if(j<15)
{
Eng[j]=new String();
Chi[j]=new String();
Eng[j]=str.substring(0,i);
Chi[j]=str.substring(i+1);

}
if(cho.getItemCount()<=15)
cho.add(Eng[j]);
tex.setText(" ");
j++;
}
}
public void itemStateChanged(ItemEvent e)
{
int dex;
dex=cho.getSelectedIndex();
lab2.setText(Chi[dex-1]);
}
}

搜索更多相关的解决方案: 感谢  分享  

----------------解决方案--------------------------------------------------------
运行不了?!还是有逻辑错误?!
----------------解决方案--------------------------------------------------------
不是吧,我运行好了才发上来的,你运行是什么错误啊,我的jdk 是1.4,你的呢??
好好看看啊,哥们!!!!
----------------解决方案--------------------------------------------------------
写的不错!
----------------解决方案--------------------------------------------------------

你的程序要完成的是什么啊???
好象没有达到要达到的目的吧!


----------------解决方案--------------------------------------------------------
  相关解决方案