绝对布局(需要自定义每个原件的位置)
作者:互联网
public class AbsolutePosition extends JFrame{ public AbsolutePosition() { // TODO Auto-generated constructor stub setTitle("本窗口使用绝对布局"); setLayout(null); setBounds(0,0,200,150); Container c = getContentPane(); JButton b1 = new JButton("按钮1"); JButton b2 = new JButton("按钮2"); b1.setBounds(10,30,80,30); b2.setBounds(60,70,100,20); c.add(b1); c.add(b2); setVisible(true); setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); } public static void main(String[] args) { // TODO Auto-generated method stub\ new AbsolutePosition(); } }
标签:自定义,原件,布局,AbsolutePosition,public,b1,b2,new,JButton 来源: https://www.cnblogs.com/dulute/p/10577474.html