import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
import javax.swing.event.*;
public class abc extends JFrame implements ActionListener
{
public abc()
{
JTextField jt1=new JTextField(20);
JTextField jt2=new JTextField(20);
Label lb1=new Label("请输入你要查找的汉字:");
Label lb2=new Label(" 它的前十个汉字为:");
Button btn1=new Button("确定");
Container container=getContentPane();
container.setLayout(new FlowLayout(FlowLayout.LEFT));
container.add(lb1);
container.add(jt1);
container.add(lb2);
container.add(jt2);
container.add(btn1);
btn1.addActionListener(this);
setSize(400,120);
setVisible(true);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
public void actionPerformed(ActionEvent e)
{
if(e.getSource()==btn1)
jt1.setText("你好!!");
}
public static void main(String args[]){
new abc();
}
}
----------------解决方案--------------------------------------------------------
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
import javax.swing.event.*;
public class abc extends JFrame implements ActionListener
{
private Button btn1;
private JTextField jt1;
public abc()
{
jt1=new JTextField(20);
JTextField jt2=new JTextField(20);
Label lb1=new Label("请输入你要查找的汉字:");
Label lb2=new Label(" 它的前十个汉字为:");
btn1=new Button("确定");
Container container=getContentPane();
container.setLayout(new FlowLayout(FlowLayout.LEFT));
container.add(lb1);
container.add(jt1);
container.add(lb2);
container.add(jt2);
container.add(btn1);
btn1.addActionListener(this);
setSize(400,120);
setVisible(true);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
public void actionPerformed(ActionEvent e)
{
if(e.getSource()==btn1)
jt1.setText("你好!!");
}
public static void main(String args[]){
new abc();
}
}
变量作用域的问题
----------------解决方案--------------------------------------------------------
斑竹,我看了没发现什么汉字查询的功能
只是点击后,在文本框设置了您好!的东东!
----------------解决方案--------------------------------------------------------
呵呵,那是,我只是把它改得可以运行了
具体功能要它自己去实现
----------------解决方案--------------------------------------------------------
呵呵,那是,我只是把它改得可以运行了
具体功能要它自己去实现
谢谢版主
----------------解决方案--------------------------------------------------------