📄 myfirstframe.java
字号:
import java.awt.*;
import java.awt.event.*;
public class myfirstframe {
static Frame frm = new Frame("this is my first Frame");
static Button but = new Button("Exit");
static Button but1 = new Button("o k");
public static void main(String[] args){
Panel pel= new Panel();
Panel pel2 =new Panel();
FlowLayout flow =new FlowLayout(FlowLayout.LEFT);
frm.setLayout(flow);
frm.setSize(300,300);
Label lab =new Label("liang");
Label lab2 =new Label("myfirstframe");
Label lab3=new Label("my name is liangdingshi");
frm.add(lab3);
pel.setLayout(flow);
pel2.setLayout(flow);
pel.add(but);
pel.add(lab);
pel2.add(but1);
pel2.add(lab2);
frm.add(pel);
frm.add(pel2);
but.addActionListener(new actionl());
but1.addActionListener(new actionl());
frm.setVisible(true);
}
static class actionl implements ActionListener{
public void actionPerformed(ActionEvent e){
Button but3 =(Button)e.getSource();
if (but3==but)
System.exit(0);
else
frm.setBackground(Color.yellow);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -