当前位置: 首页 > news >正文

如果只做p2p种子搜索网站四川网站建设咨询

如果只做p2p种子搜索网站,四川网站建设咨询,网站构架图怎么做,小学做试题网站在一个传统的java项目中#xff0c;遇到一个需要调整布局的需求#xff0c;下面将学习网上大佬的文章#xff0c;并将过程记录下来。 1、Java swing5种布局方式 1、 边界布局#xff08;BorderLayout#xff09;2、流式布局#xff08;FlowLayout#xff09;3、网格布局… 在一个传统的java项目中遇到一个需要调整布局的需求下面将学习网上大佬的文章并将过程记录下来。 1、Java swing5种布局方式 1、 边界布局BorderLayout2、流式布局FlowLayout3、网格布局GridLayout4、盒子布局BoxLaYout5、空布局null 还有其他两种布局分别是GridBagLayout网格包布局、CardLayout卡片布局。 注意JFrame和JDialog默认布局为BorderLayoutJPanel和Applet默认布局为FlowLayout。 2、边界布局BorderLayout 实例如下 public class BorderLayoutExample extends JFrame {JButton btn1new JButton(东);JButton btn2new JButton(南);JButton btn3new JButton(西);JButton btn4new JButton(北);JButton btn5new JButton(中);BorderLayoutExample(){init();this.setTitle(边界布局);this.setResizable(true);this.setSize(300, 300);this.setLocationRelativeTo(null);this.setDefaultCloseOperation(EXIT_ON_CLOSE);this.setVisible(true);}void init(){this.setLayout(new BorderLayout(10,5)); //默认为00水平间距10垂直间距5this.add(btn1,BorderLayout.EAST);this.add(btn2,BorderLayout.SOUTH);this.add(btn3,BorderLayout.WEST);this.add(btn4,BorderLayout.NORTH);this.add(btn5,BorderLayout.CENTER);}public static void main(String args[]){new BorderLayoutExample();} }运行结果如下 3、流式布局FlowLayout 实例如下 public class FlowLayoutExample extends JFrame {JButton btn1new JButton(one);JButton btn2new JButton(two);JButton btn3new JButton(three);JButton btn4new JButton(four);JButton btn5new JButton(five);FlowLayoutExample(){init();this.setTitle(流式布局);this.setResizable(true);this.setSize(300, 300);this.setLocationRelativeTo(null);this.setDefaultCloseOperation(EXIT_ON_CLOSE);this.setVisible(true);}void init(){this.setLayout(new FlowLayout(FlowLayout.LEFT,10,5)); //默认为居中;水平间距10垂直间距5this.add(btn1);this.add(btn2);this.add(btn3);this.add(btn4);this.add(btn5);}public static void main(String args[]){new FlowLayoutExample();} }运行结果如下 4、网格布局GridLayout 实例如下 public class GridLayoutExample extends JFrame {JButton btn1new JButton(one);JButton btn2new JButton(two);JButton btn3new JButton(three);JButton btn4new JButton(four);JButton btn5new JButton(five);GridLayoutExample(){init();this.setTitle(表格布局);this.setResizable(true);this.setSize(300, 300);this.setLocationRelativeTo(null);this.setDefaultCloseOperation(EXIT_ON_CLOSE);this.setVisible(true);}void init(){this.setLayout(new GridLayout(2,3,10,5)); //默认为1行n列2行3列水平间距10垂直间距5this.add(btn1);this.add(btn2);this.add(btn3);this.add(btn4);this.add(btn5);}public static void main(String args[]){new GridLayoutExample();} }运行结果如下 5、盒子布局BoxLaYout 实例如下 public class BoxLayoutExample extends JFrame {JButton btn1new JButton(one);JButton btn2new JButton(two);JButton btn3new JButton(three);JButton btn4new JButton(four);JButton btn5new JButton(five);BoxLayoutExample(){init();this.setTitle(表格布局);this.setResizable(true);this.setSize(300, 300);this.setLocationRelativeTo(null);this.setDefaultCloseOperation(EXIT_ON_CLOSE);this.setVisible(true);}void init(){this.setLayout(new BoxLayout(this.getContentPane(),BoxLayout.X_AXIS));//可以使用Box容器代替//Box box new Box(BoxLayout.Y_AXIS);box.add(btn...);box.add(creat..);this.add(btn1);this.add(btn2);this.getContentPane().add(Box.createHorizontalStrut(10)); //采用x布局时添加固定宽度组件隔开//this.getContentPane().add(Box.createVerticalStrut(5)); //采用y布局时添加固定高度组件隔开this.add(btn3);this.add(btn4);this.add(btn5);}public static void main(String args[]){new BoxLayoutExample();} }运行结果如下 6、空布局null 实例如下 public class NullLayoutExample extends JFrame {JButton btn1new JButton(one);JButton btn2new JButton(two);JButton btn3new JButton(three);JButton btn4new JButton(four);JButton btn5new JButton(five);NullLayoutExample(){init();this.setTitle(空布局);this.setResizable(true);this.setSize(300, 300);this.setLocationRelativeTo(null);this.setDefaultCloseOperation(EXIT_ON_CLOSE);this.setVisible(true);}void init(){this.setLayout(null);btn1.setBounds(10, 0, 100, 50); //x坐标10y坐标0组件宽100高50btn2.setBounds(20, 50, 100, 50);btn3.setBounds(30, 100, 100, 50);btn4.setBounds(40, 150, 100, 50);btn5.setBounds(50, 200, 100, 50);this.add(btn1);this.add(btn2);this.add(btn3);this.add(btn4);this.add(btn5);}public static void main(String args[]){new NullLayoutExample();} }运行结果如下 注感兴趣的小伙伴可以试试可以直接运行
http://www.zqtcl.cn/news/20063/

相关文章:

  • 承德建设网站渭南自建站网站建设
  • html网站尺寸链接交换
  • 网站首页快照不更新衡水网站建
  • 网站怎么做伪静态页面做设计任务的网站
  • 天涯论坛网站建设怎么让百度收录网址
  • 做全世界的生意的网站住房和城乡建设部网站办事大厅里边
  • 注册网站会员需要详细杭州手机软件开发
  • 企业模板建站有哪些wordpress 创意
  • 免费申请公司网站网站建设的软件有哪些
  • 移动互联网站建设有赞微商城小程序
  • 汕头网站建设方案优化网页制作的教程视频
  • 建设一个最普通网站要多少钱宜昌的网站建设
  • 网站文章模板成都营销推广公司
  • 中小企业网站积木式搭建公司法全文
  • php在网站后台建设中的优势免费咨询服务合同范本
  • 谷歌建站多少钱青田县建设局网站
  • 长沙做网站有哪些重庆招标建设信息网站
  • 南京铁路建设网站安卓程序开发
  • 门户网站建设开发企业可以做哪些网站
  • 网站推广经典案例公众号文章排版
  • 平台网站怎么建设东莞网站建设方案托管
  • 罗湖网站建设58本地电脑做网站服务器
  • 自己做付费网站做体力活的网站
  • 创研科技网站WordPress qinmei影视主题
  • 关于小城镇建设的网站单位装专用的网站网页归档
  • 电子商务综合实训报告网站建设做视频网站违法
  • 淄博企业网站建设网站建站网站制作公司
  • centos建设网站东莞三网合一网站制作
  • 石家庄中小企业网站制作上海网上推广优化
  • 提供网站建设设计外包php自己做网站吗