java程序填空题
importjava.awt.*;importjava.awt.event.*;importjavax.swing.*;publicclassHelloextends(1...
import java.awt.*;
import java.awt.event.* ;
import javax.swing.* ;
public class Hello extends (1) implements (2) {
JTextArea tf;
JButton bt_show,bt_clear,bt_exit;
public Hello( ){
super("Hello");
Container c=getContentPane( );
bt_show=new JButton("显示"); //创建一文本为"显示"的按钮
bt_clear=new JButton("清除");//创建一文本为"清除"的按钮
bt_exit=new JButton("退出");//创建一文本为"退出"的按钮
tf=new JTextArea(5,30);
c .setLayout (new FlowLayout());
c .add (bt_show);
c .add (bt_clear);
c .add (bt_exit);
c .add (tf);
bt_show. (3) (this);
bt_clear. (3) (this);
bt_exit. (3) (this);
setSize(350,200);//设置界面大小
setLocation(200,200) ;//设置界面位置
setVisible(true);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setDefaultLookAndFeelDecorated(true);
}
public void (4) (ActionEvent e){
if(e.getSource()==bt_show) //判断事件源是否是bt_show
tf .setText("欢迎你学习Java!");
else if( (5) ) //判断事件源是否是bt_clear
tf .setText(" ");
else
System.exit(0);
}
public static void main (String[]args){
Hello fm=new Hello();
}
} 展开
import java.awt.event.* ;
import javax.swing.* ;
public class Hello extends (1) implements (2) {
JTextArea tf;
JButton bt_show,bt_clear,bt_exit;
public Hello( ){
super("Hello");
Container c=getContentPane( );
bt_show=new JButton("显示"); //创建一文本为"显示"的按钮
bt_clear=new JButton("清除");//创建一文本为"清除"的按钮
bt_exit=new JButton("退出");//创建一文本为"退出"的按钮
tf=new JTextArea(5,30);
c .setLayout (new FlowLayout());
c .add (bt_show);
c .add (bt_clear);
c .add (bt_exit);
c .add (tf);
bt_show. (3) (this);
bt_clear. (3) (this);
bt_exit. (3) (this);
setSize(350,200);//设置界面大小
setLocation(200,200) ;//设置界面位置
setVisible(true);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setDefaultLookAndFeelDecorated(true);
}
public void (4) (ActionEvent e){
if(e.getSource()==bt_show) //判断事件源是否是bt_show
tf .setText("欢迎你学习Java!");
else if( (5) ) //判断事件源是否是bt_clear
tf .setText(" ");
else
System.exit(0);
}
public static void main (String[]args){
Hello fm=new Hello();
}
} 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询