资源简介
1.编写Application程序,在Frame中加入2个按钮(Button)和1个标签(Label),单击两个按钮,显示按钮的标签于Label。
2.在Application中加入1个文本框,1个文本区,每次在文本框中输入文本,回车后将文本添加到文本区的最后一行。
3.在Application中加入2个复选框,显示标题为“学习”和“玩耍”,根据选择的情况,分别显示“玩耍”、“学习”、“劳逸结合”。
4.在Application中加入1个滚 动列表框List、1个下拉列表框ComboBox和1个按钮,点击按钮将List中的项目移到ComboBox组件中。
代码片段和文件信息
import java.awt.event.*;
import javax.swing.*;
import java.awt.*;
public class Exp8_1 extends Jframe implements ActionListener
{
/**
*
*/
private static final long serialVersionUID = 817252507815408383L;
JButton bt_1bt_2;
JLabel lb_1;
public Exp8_1()
{
initComponent(); //初始化组件
setLayout(new FlowLayout()); //设置布局
this.setSize(200 200);
this.setVisible(true);
this.setDefaultCloseOperation(DISPOSE_ON_CLOSE);
}
public void initComponent() {
bt_1=new JButton(“bt_1“);
bt_2=new JButton(“bt_2“);
lb_1=new JLabel(“ label “);
add(bt_1);
add(bt_2);
add(lb_1);
bt_1.addActionListener(this); //事件监听
bt_2.addActionListener(this);
}
public void actionPerformed(ActionEvent e)
{
lb_1.setText(e.getActionCommand());
}
public static void main(String[] args)
{
new Exp8_1();
}
}
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 944 2020-05-22 08:57 源文件\Exp8_1.java
文件 1032 2020-05-21 14:38 源文件\Exp8_2.java
文件 968 2020-05-21 14:42 源文件\Exp8_3.java
文件 1180 2020-05-21 14:33 源文件\Exp8_4.java
目录 0 2020-05-21 19:43 源文件
----------- --------- ---------- ----- ----
4124 5
- 上一篇:银行信息管理系统软件需求说明书.docx
- 下一篇:MOSI DATASET
评论
共有 条评论