簡體   English   中英

如何在Java swing中創建3個按鈕以占據添加到它們的面板的1/3?

[英]How to create 3 buttons in java swing to take 1/3 of the panel that they are added to?

private JPanel createControlPanel() {
    JPanel ctrl = new JPanel();
    addBorder(ctrl,"Controls");
    //add 3 buttons here

    return ctrl;
    }

我想創建這3個按鈕並將其添加到ctrl

從文檔中:

GridLayout experimentLayout = new GridLayout(1,3);
compsToExperiment.setLayout(experimentLayout);

compsToExperiment.add(new JButton("Button 1"));
compsToExperiment.add(new JButton("Button 2"));
compsToExperiment.add(new JButton("Button 3"));

文件

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM