?? myframe.java
字號:
import java.awt.*;
import java.awt.event.*;
public class MyFrame
{
public static void main(String args[])
{
new Frame1();
}
}
class Frame1 extends Frame implements ActionListener
{
Button btn;
Frame1()
{
super("我的窗口");
btn=new Button("關閉");
setLayout(new FlowLayout());
add(btn);
btn.addActionListener(this);
addWindowListener(new CloseWin());
setSize(300,200);
setVisible(true);
}
public void actionPerformed(ActionEvent e)
{
if(e.getActionCommand()=="關閉")
{
dispose();
System.exit(0);
}
}
}
class CloseWin extends WindowAdapter
{
public void windowClosing(WindowEvent e)
{
if((e.getSource()) instanceof Frame){
Frame frm=(Frame)(e.getSource());
frm.dispose();
System.exit(0);
}
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -