zoukankan      html  css  js  c++  java
  • GUI 之流布局

    编写代码 TestFlowLayout测试类

    package com.xiang.lesson01;
    
    import java.awt.*;
    import java.awt.event.WindowAdapter;
    import java.awt.event.WindowEvent;
    
    //流式布局
    public class TestFlowLayout {
        public static void main(String[] args) {
            Frame frame = new Frame();
    
    //        按钮 组件
            Button button1 = new Button("but01");
            Button button2 = new Button("but02");
            Button button3 = new Button("but03");
            Button button4 = new Button("but04");
    //设置为流式布局
    //        frame.setLayout(new FlowLayout());//居中
    //        frame.setLayout(new FlowLayout(FlowLayout.LEFT));//居左
            frame.setLayout(new FlowLayout(FlowLayout.RIGHT));//居左
    
            frame.setBounds(400,400,400,400);
    //        添加按钮
            frame.add(button1);
            frame.add(button2);
            frame.add(button3);
            frame.add(button4);
    
            frame.setVisible(true);
    
            frame.addWindowListener(new WindowAdapter() {
                //窗口关闭要作的事情
                @Override
                public void windowClosing(WindowEvent e) {
    //                结束程序
                    System.exit(0);
                }
            });
        }
    
    }
    
    

    运行结果

  • 相关阅读:
    MyBatis 配置文件 用户密码加密存储
    MyBatis 实例
    mybatis 入门搭建
    文件上传
    struts 结果类型
    Struts 拦截器
    log4j
    Struts Action 控制器
    Struts
    四、常用的Maven命令
  • 原文地址:https://www.cnblogs.com/d534/p/15104201.html
Copyright © 2011-2022 走看看