zoukankan      html  css  js  c++  java
  • 吴裕雄--天生自然JAVA图形界面编程学习笔记:布局管理器

    import java.awt.FlowLayout ;
    import javax.swing.JFrame ;
    import javax.swing.JButton ;
    import javax.swing.JLabel ;
    
    public class AbsoluteLayoutDemo01{
        public static void main(String args[]){
            JFrame frame = new JFrame("Welcome To MLDN") ; 
            frame.setLayout(null) ;
            JLabel title = new JLabel("www.mldnjava.cn") ;
            JButton enter = new JButton("进入") ;
            JButton help = new JButton("帮助") ;
            frame.setSize(280,123) ;
            title.setBounds(45,5,150,20) ;
            enter.setBounds(10,30,80,20) ;
            help.setBounds(100,30,80,20) ;
            frame.add(title) ;
            frame.add(enter) ;
            frame.add(help) ;
            frame.setVisible(true) ;
        }
    };
    import java.awt.BorderLayout ;
    import javax.swing.JFrame ;
    import javax.swing.JButton ;
    
    public class BorderLayoutDemo01{
    	public static void main(String args[]){
    		JFrame frame = new JFrame("Welcome To MLDN") ; 
    		frame.setLayout(new BorderLayout(3,3)) ;
    		frame.add(new JButton("东(EAST)"),BorderLayout.EAST) ;
    		frame.add(new JButton("西(WEST)"),BorderLayout.WEST) ;
    		frame.add(new JButton("南(SOUTH)"),BorderLayout.SOUTH) ;
    		frame.add(new JButton("北(NORTH)"),BorderLayout.NORTH) ;
    		frame.add(new JButton("中(CENTER)"),BorderLayout.CENTER) ;
    		frame.setSize(280,123) ;
    		frame.setVisible(true) ;
    	}
    };
    

      

    import java.awt.CardLayout ;
    import java.awt.Container ;
    import javax.swing.JFrame ;
    import javax.swing.JLabel ;
    
    public class CardLayoutDemo01{
        public static void main(String args[]){
            JFrame frame = new JFrame("Welcome To MLDN") ; 
            CardLayout card = new CardLayout() ;
            frame.setLayout(card) ;
            Container con = frame.getContentPane() ;
            con.add(new JLabel("标签-A",JLabel.CENTER),"first") ;
            con.add(new JLabel("标签-B",JLabel.CENTER),"second") ;
            con.add(new JLabel("标签-C",JLabel.CENTER),"thrid") ;
            con.add(new JLabel("标签-D",JLabel.CENTER),"fourth") ;
            con.add(new JLabel("标签-E",JLabel.CENTER),"fifth") ;
            frame.pack() ;
            frame.setVisible(true) ;
            card.show(con,"thrid") ;
            for(int i=0;i<5;i++){
                try{
                    Thread.sleep(3000) ;
                }catch(InterruptedException e){}
                card.next(con) ;
            }
            
        }
    };
    import java.awt.FlowLayout ;
    import javax.swing.JFrame ;
    import javax.swing.JButton ;
    
    public class FlowLayoutDemo01{
        public static void main(String args[]){
            JFrame frame = new JFrame("Welcome To MLDN") ; 
            frame.setLayout(new FlowLayout(FlowLayout.CENTER,3,3)) ;
            JButton but = null ;
            for(int i=0;i<9;i++){
                but = new JButton("按钮-"+ i) ;
                frame.add(but) ;
            }
            frame.setSize(280,123) ;
            frame.setVisible(true) ;
        }
    };
    import java.awt.GridLayout ;
    import javax.swing.JFrame ;
    import javax.swing.JButton ;
    
    public class GridLayoutDemo01{
        public static void main(String args[]){
            JFrame frame = new JFrame("Welcome To MLDN") ; 
            frame.setLayout(new GridLayout(3,5,3,3)) ;
            JButton but = null ;
            for(int i=0;i<13;i++){
                but = new JButton("按钮-"+ i) ;
                frame.add(but) ;
            }
            frame.pack() ;
            frame.setVisible(true) ;
        }
    };
  • 相关阅读:
    python---RabbitMQ(1)简单队列使用,消息依次分发(一对一),消息持久化处理
    python---ORM之SQLAlchemy(4)relationship多对多练习
    ShowcaseView-master
    HT518V311
    上方显示进度的进度条
    ArrowDrawable
    一个仿 github for windows 及 windows 8 的进度条
    高仿语音发送动画,按住闪烁,滑动跟随,删除翻转丢入垃圾桶,比较全的一个动画实例
    Ledongli
    RotatingDoughnut
  • 原文地址:https://www.cnblogs.com/tszr/p/12398794.html
Copyright © 2011-2022 走看看