?? graphicsappinout.java
字號:
import java.awt.*; //引入java.awt包中的所有類
import java.awt.event.*;
public class GraphicsAppInOut //定義主類GraphicsAppInOut
{
public static void main(String args[]) //定義主類中的main方法
{
ApplctFrame MyFrame = new ApplctFrame();//創建對象MyFrame,形成圖形界面
}
}
class ApplctFrame extends Frame
implements ActionListener //定義Frame類的子類ApplctFrame
{
Label prompt; //定義提示標簽對象
TextField input; //定義輸入單行文本區域對象
Label output; //定義輸出標簽對象
ApplctFrame() //對ApplctFrame對象初始化
{
super("Application Graphics Frame"); //調用父類方法指定圖形界面窗口標題
setLayout(new FlowLayout()); //指定圖形界面窗口中各部件的排列方式
prompt = new Label("Enter a character please: "); //創建提示標簽對象
input = new TextField(4); //創建輸入單行文本區域對象
output = new Label(" ");//創建輸出標簽對象
add(prompt); //將提示標簽加入窗口
add(input); //將輸入區域加入窗口
add(output); //將輸出標簽加入窗口
input.addActionListener(this);
this.addWindowListener(new WindowAdapter()
{
public void windowClosing(WindowEvent we)
{
System.exit(0);
}
});
setSize(500,100);
setVisible(true);
}
public void actionPerformed(ActionEvent e) //參見例2.2注釋
{
output.setText("character:"+input.getText());
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -