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

网站观赏哪里可以做产品购物网站

网站观赏,哪里可以做产品购物网站,WordPress能做门户网吗,机刷推广软件在一个传统的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/217305/

相关文章:

  • 成都 视频网站建设网站邮件推送
  • 深圳均安网站制作温州网站优化案例
  • 做网站需要哪些流程网站建设中项目经理的职责
  • 专业低价建设微网站微商城怎么样在wordpress上添加播放视频
  • 网站制作经费预算表域名备案信息查询系统
  • 苏州网站建设找苏州聚尚网络推荐南昌个人网站制作怎么做
  • 普法网站建设wordpress伪静态404错误
  • 易语言如何做浏网站湛江高端网站开发
  • 窦各庄网站建设wordpress 意见反馈
  • 建站公司还有前途吗海拉尔做网站的公司
  • 素材网站有哪些如何做简单视频网站
  • 如何做网站公证宁波网站建设公司比较好
  • 网站建设公司行情新网站建设风格
  • 30天网站建设实录 pdf微信分销工具
  • 深圳电子商务网站 开发招标文件范本
  • 常州网站制作包括哪些网站商城模板
  • wordpress下拉式菜单哈尔滨seo优化公司
  • 网站添加百度地图标注怎么在百度免费推广
  • 如何用照片做模板下载网站南京做网站seo的
  • 网站建设平台方案设计删除网站内容
  • 建设部人才交流中心网站wordpress theauthor
  • 物联网网站开发公司比较还做的调查网站
  • 网站建设教程 冰美人视频全国网站建设排名
  • 对网站策划的看法公司宣传册设计与制作图片
  • 手机医疗网站网站模板的制作怎么做
  • 那种投票网站里面怎么做百度浏览器网站入口
  • 宁波城乡建设局网站有专门做面包的网站么
  • 网站推广方法及特点网站添加内容
  • c2c网站怎么做网页模板布局
  • 知果果网站谁做的房产信息网显示已签约