import javax.swing.*;//单纯的面板
import java.awt.*;
public class Panel1
{
public static void main(String [] args)
{
Panel1 gui=new Panel1();
gui.go();
}
public void go()
{
JFrame frame = new JFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JPanel panel = new JPanel();
panel.setBackground(Color.darkGray);
frame.getContentPane().add(BorderLayout.EAST,panel);
frame.setSize(200,200);
frame.setVisible(true);
}
}
import java.awt.*;//加3个按钮到面板上
public class Panel2
{
public static void main(String [] args)
{
Panel2 gui=new Panel2();
gui.go();
}
public void go()
{
JFrame frame = new JFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JPanel panel = new JPanel();
JButton button = new JButton("shock me");
JButton buttonTwo= new JButton("bliss");
JButton buttonThree = new JButton("huh?");
panel.setBackground(Color.darkGray);
panel.add(button);
panel.add(buttonTwo);
panel.add(buttonThree);
frame.getContentPane().add(BorderLayout.EAST,panel);
frame.setSize(250,200);
frame.setVisible(true);
}
}
import javax.swing.*;
import java.awt.*;//加2个按钮到面板上
public class Panel2
{
public static void main(String [] args)
{
Panel2 gui=new Panel2();
gui.go();
}
public void go()
{
JFrame frame = new JFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JPanel panel = new JPanel();
JButton button = new JButton("shock me");
JButton buttonTwo= new JButton("bliss");
panel.setBackground(Color.darkGray);
panel.add(button);
panel.add(buttonTwo);
frame.getContentPane().add(BorderLayout.EAST,panel);
frame.setSize(250,200);
frame.setVisible(true);
}
}