📄 border.java
字号:
import java.awt.*;
import java.awt.event.*;
public class border extends Frame{
Label txt=new Label("null");
Button bnorth=new Button("North");
Button bsouth=new Button("South");
Button beast=new Button("East");
Button bwest=new Button("West");
public border(String ss){
super(ss);
this.setLayout(new BorderLayout());
bnorth.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
processAction(e);}
} );
bsouth.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
processAction(e);}
} );
beast.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
processAction(e);}
} );
bwest.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
processAction(e);}
} );
add("North",bnorth);
add("South",bsouth);
add("East",beast);
add("West",bwest);
add("Center",txt);
}
public static void main(String[] args){
border nowframe=new border("BorderLayout");
nowframe.addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent e){
System.exit(0);
}
});
nowframe.pack();
nowframe.show();
}
public Dimension getPreferredSize()
{
return new Dimension(300,300);
}
public void processAction(ActionEvent e){
Object obj=e.getSource();
if(obj==bnorth) txt.setText("北");
if(obj==beast) txt.setText("东");
if(obj==bwest) txt.setText("西");
if(obj==bsouth) txt.setText("南");}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -