package com.charpter13;
import java.awt.Container;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.WindowConstants;
public class Repeat1 extends JFrame {
//绝对布局
public Repeat1()
{
setTitle("绝对布局例子");
setLayout(null);
Container container=getContentPane();
JLabel jl=new JLabel("这是绝对布局窗口");
setBounds(0, 0, 300, 300);
JButton b1=new JButton("按钮1");
JButton b2=new JButton("按钮2");
b1.setBounds(10, 10, 60, 80);
b2.setBounds(80, 90, 60, 60);
container.add(b1);
container.add(b2);
setVisible(true);
setSize(600, 300);
setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
}
public static void main(String[] args) {
new Repeat1();
}
}
import java.awt.Container;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.WindowConstants;
public class Repeat1 extends JFrame {
//绝对布局
public Repeat1()
{
setTitle("绝对布局例子");
setLayout(null);
Container container=getContentPane();
JLabel jl=new JLabel("这是绝对布局窗口");
setBounds(0, 0, 300, 300);
JButton b1=new JButton("按钮1");
JButton b2=new JButton("按钮2");
b1.setBounds(10, 10, 60, 80);
b2.setBounds(80, 90, 60, 60);
container.add(b1);
container.add(b2);
setVisible(true);
setSize(600, 300);
setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
}
public static void main(String[] args) {
new Repeat1();
}
}