正在加载图片...
import java. awt. i import javax. swing. i class frame flow extends jframe FrameFlow (string name { super(name); Container contenetPane=this getContentPane; Flow Layout flow Layout=new Flow Layout flow Layout. setAlignment( FlowLayout LEFT)//设置布局的对齐方式 flowLayout. setHgap(4) /设置组件的水平间距 flow Layout. setVgap(6); //设置组件的垂直间距 contenetPane. setlayout( flow Layout);//设置容器的布局为 flow Layout for(int i=1;i<=10;i++) contenetPane ado( new JButton("按钮"+i)//把按钮加入容器 contenetPane validated //设置容器有效 setBounds(50, 50, 100, 100); setsize(300, 300); setvisible( true); /设置组件可见 setDefaultCloseOperation( JFrame DISPOSE_ON_ CLOSE)//关闭容口, Example 1.javaimport java.awt.*; import javax.swing.*; class FrameFlow extends JFrame { FrameFlow(String name) { super(name); Container contenetPane=this.getContentPane(); FlowLayout flowLayout=new FlowLayout(); flowLayout.setAlignment(FlowLayout.LEFT); //设置布局的对齐方式 flowLayout.setHgap(4); //设置组件的水平间距 flowLayout.setVgap(6); //设置组件的垂直间距 contenetPane.setLayout(flowLayout); //设置容器的布局为flowLayout for(int i=1;i<=10;i++) { contenetPane.add(new JButton("按钮 "+i)); //把按钮加入容器 } contenetPane.validate(); //设置容器有效 setBounds(50,50,100,100); setSize(300,300); setVisible(true); //设置组件可见 setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); //关闭容口, Example8_1 .java
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有