JPanel和 J Button使用示例 import java. awt.* import javax. swing. *i class PanelDemo extends JFrame public PanelDemo( String title)i super(title)i Container c=getcontentPane ()i JPanel pane new JPanelo JButton ok= new JButton("确定"); public static void main(string args[])[ Pane⊥ Demo pd= new PanelDe g pAne测试 pd setsize(300, 200)i pa setvisible(true)i 确定取消 Designed by Chiyong C200518 Designed by Chiyong,©2005 JPanel和JButton使用示例 import java.awt.*; import javax.swing.*; class PanelDemo extends JFrame { public PanelDemo( String title){ super(title); Container c=getContentPane(); JPanel cpane = new JPanel(); JButton ok = new JButton("确定"); cpane.add(ok); JButton cancel = new JButton("取消"); cpane.add(cancel); c.add(cpane,BorderLayout.SOUTH); } public static void main(String args[]) { PanelDemo pd=new PanelDemo("JPanel测试"); pd.setSize(300,200); pd.setVisible(true); } }