資源簡介
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
評論
共有 條評論