Box布局

作者: 开心的小哈 | 来源:发表于2021-11-08 12:32 被阅读0次
    package com.main;
    
    import javax.swing.*;
    import javax.swing.event.MenuEvent;
    import javax.swing.event.MenuListener;
    import java.awt.*;
    import java.awt.event.*;
    
    public class MassageDialogDeom {
        public void init(){
    
            Frame jFrame=new Frame("test Menu");
    
            Box horizontalBox = Box.createHorizontalBox();
            horizontalBox.add(new Button("no1"));
            horizontalBox.add(Box.createHorizontalGlue());
            horizontalBox.add(new Button("no2"));
            horizontalBox.add(Box.createHorizontalStrut(30));
            horizontalBox.add(new Button("no3"));
    
            Box verticalBox = Box.createVerticalBox();
            verticalBox.add(new Button("no1"));
            verticalBox.add(Box.createVerticalGlue());
            verticalBox.add(new Button("no2"));
            verticalBox.add(Box.createVerticalStrut(30));
            verticalBox.add(new Button("no3"));
    
            jFrame.add(horizontalBox,BorderLayout.NORTH);
            jFrame.add(verticalBox);
            jFrame.pack();
            jFrame.setVisible(true);
        }
    
        public static void main(String[] args) {
            new MassageDialogDeom().init();
    
        }
    }
    
    
    image.png

    相关文章

      网友评论

          本文标题:Box布局

          本文链接:https://www.haomeiwen.com/subject/luyyzltx.html