[英]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.