package java1;
//面板Panel
import javax.swing.*;
import java.awt.Color;
import java.awt.FlowLayout;
import java.awt.Panel;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class Atn extends JFrame {
Panel panel =new Panel();
Panel panel2 =new Panel();
JButton jButton1 = new JButton("Button1");
JButton jButton2 = new JButton("Button2");
JButton jButton3 = new JButton("Button3");
JButton jButton4 = new JButton("Button3");
public Atn()
{
setSize(900,500);
setVisible(true);
setTitle("面板容器示例");
setDefaultCloseOperation(EXIT_ON_CLOSE);
setLayout(new FlowLayout());
add(panel);
add(panel2);
panel.add(jButton1);
panel.add(jButton2);
panel2.add(jButton3);
panel2.add(jButton4);
panel.setBackground(Color.red);
panel2.setBackground(Color.green);
validate();
}
}
package java1;
public class Text {
public static void main(String[] args) {
new Atn();
}
}