📄 windowtest.java
字号:
import java.awt.*;
import java.awt.event.*;
class WindowTest implements ActionListener
{
Frame f=new Frame("Window示例");
Window w=new Window(f);
Label l=new Label("这是一个弹出式Window");
Button btn1=new Button("弹出Window");
Button btn2=new Button("结束程序");
public WindowTest()
{
w.setForeground(Color.white);
w.setBackground(Color.blue);
w.add(l);
w.pack();
w.setLocation(250,200);
btn1.addActionListener(this);
btn2.addActionListener(this);
f.setLayout(new FlowLayout());
f.add(btn1);
f.add(btn2);
f.setSize(200,150);
f.setVisible(true);
}
public void actionPerformed(ActionEvent e)
{
Button b=(Button)e.getSource();
if(b==btn1)
w.show();
else if(b==btn2)
System.exit(0);
}
public static void main(String args[])
{
new WindowTest();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -