日期:2014-05-20 浏览次数:20778 次
public class TestsetLayout extends JFrame { /** * Leaning * TestsetLayout .java * TODO * 2011-9-20 */ private static final long serialVersionUID = 1L; /** * */ public TestsetLayout () { Button btn=new Button("ok"); btn.setBackground(new Color(0,0,255)); add(btn); setLayout(null); setBounds(20,20,30,30); pack(); this.setVisible(true); } /** * @param args */ public static void main(String[] args) { TestsetLayout t=new TestsetLayout (); } }
import java.awt.*; import java.awt.event.*; import javax.swing.*; import javax.swing.event.*; public class TestsetLayout extends JFrame { /** * Leaning * TestsetLayout .java * TODO * 2011-9-20 */ private static final long serialVersionUID = 1L; /** * */ public TestsetLayout () { Button btn=new Button("ok"); btn.setBounds(0,0,200,200); btn.setBackground(new Color(0,0,255)); add(btn); setLayout(null); setBounds(20,20,300,300); this.setSize(300,300); // pack(); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); this.setVisible(true); } /** * @param args */ public static void main(String[] args) { TestsetLayout t=new TestsetLayout (); } }