标签:listen adapter sys mic ati color listener tla enter
layout可以叠加效果
import java.awt.*;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
public class HomeWork {
public static void main(String[] args) {
Frame frame = new Frame();
frame.setSize(400,400);
frame.setLocation(300,300);
frame.setBackground(Color.black);
frame.setVisible(true);
frame.setLayout(new GridLayout(2,1));
Panel panel1 = new Panel(new BorderLayout());
Panel panel2 = new Panel(new GridLayout(2, 1));
Panel panel3 = new Panel(new BorderLayout());
Panel panel4 = new Panel(new GridLayout(2, 2));
panel1.add(new Button("east-1"),BorderLayout.EAST);
panel1.add(new Button("west-1"),BorderLayout.WEST);
panel2.add(new Button("p2-b1"));
panel2.add(new Button("p2-b2"));
panel1.add(panel2,BorderLayout.CENTER);
panel3.add(new Button("east-2"),BorderLayout.EAST);
panel3.add(new Button("west-2"),BorderLayout.WEST);
panel4.add(new Button("p2-b1"));
panel4.add(new Button("p2-b2"));
panel4.add(new Button("p2-b3"));
panel4.add(new Button("p2-b4"));
panel3.add(panel4,BorderLayout.CENTER);
frame.add(panel1);
frame.add(panel3);
frame.addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent e) {
System.exit(0);
}
});
}
}
效果
标签:listen adapter sys mic ati color listener tla enter
原文地址:https://www.cnblogs.com/pipacam/p/14771740.html