日期:2014-05-20 浏览次数:20909 次
import java.awt.*;
import javax.swing.*;
public class text extends JFrame {
private JLabel panelNorth;
private JPanel panelSouth;
private JButton but_start;
private JButton but_out;
private JPanel pan;
private BorderLayout lay;
public text() {
setTitle("面板");
lay = new BorderLayout();
setLayout(lay);
lay.setVgap(15);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(400, 100, 500, 550);
init();
setVisible(true);
}
void init() {
panelNorth = new JLabel("画线!");
panelNorth.setFont(new Font("楷体", 30, 24));
panelNorth.setForeground(Color.blue);
this.getContentPane().add(panelNorth, BorderLayout.NORTH);
panelSouth = new JPanel();
but_start = new JButton("开始");
but_out = new JButton("退出");
but_start.setFont(new Font("楷体", 10, 16));
but_out.setFont(new Font("楷体", 10, 16));
panelSouth.add(but_start);
panelSouth.add(but_out);
this.getContentPane().add(panelSouth, BorderLayout.SOUTH);
pan = new JPanel() {
@Override
public void paintComponent(Graphics g) {
super.paintComponent(g);
g.setColor(Color.black);
g.drawLine(50, 50, 100, 100);
}
};
this.getContentPane().add(pan, BorderLayout.CENTER);
}
public static void main(String args[]) {
new text();
}
}