0
之間的距離我寫了這個代碼實現一個盒子放到我放四個JradioButton將爪哇 - JLabel的垂直箱
JRadioButton beginner = new JRadioButton("Beginner"); beginner.setSelected(true);
JRadioButton intermedie = new JRadioButton("Intermedie");
JRadioButton expert = new JRadioButton("Expert");
JRadioButton custom = new JRadioButton("Custom");
Box boxDifficulty = Box.createVerticalBox();
boxDifficulty.setBorder(BorderFactory.createEmptyBorder(10, 0, 0, 50));
boxDifficulty.add(beginner);
boxDifficulty.add(intermedie);
boxDifficulty.add(expert);
boxDifficulty.add(custom);
而且我用setBorder(BorderFactory.createEmptyBorder(10, 0, 0, 50))
方法來設置框的邊框。
而且,我創建了一個JLabel用於指示框的標題:
JLabel difficulty = new JLabel("Choose the difficulty:");
這是完整的代碼部分:
Box boxDifficulty = Box.createVerticalBox();
boxDifficulty.add(difficulty);
boxDifficulty.setBorder(BorderFactory.createEmptyBorder(10, 0, 0, 50));
boxDifficulty.add(beginner);
boxDifficulty.add(intermedie);
boxDifficulty.add(expert);
boxDifficulty.add(custom);
我怎麼能增加的JLabel之間的空間一個JRadioButton?