📄 awthello.java
字号:
// AWTHello.java
import java.awt.*;
import java.awt.event.*;
class AWTHello extends Frame implements ActionListener
{
Button b;
static String [] labels =
{
"Hello! Welcome to AWT!",
"You cannot assign icons to AWT buttons."
};
int nextLabel;
AWTHello (String title)
{
super (title);
addWindowListener (new WindowAdapter ()
{
public void windowClosing (WindowEvent e)
{
System.exit (0);
}
});
Panel p = new Panel ();
b = new Button (labels [nextLabel++]);
b.addActionListener (this);
p.add (b);
add (p);
setSize (300, 100);
setVisible (true);
}
public void actionPerformed (ActionEvent e)
{
b.setLabel (labels [nextLabel++]);
validate ();
nextLabel %= labels.length;
}
public static void main (String [] args)
{
new AWTHello ("Hello, AWT Version");
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -