我想組織一個3×3盒我的按鈕。我應該使用哪種佈局,以及如何使用它?如何設置一個JRadioButton的位置?
0
A
回答
2
1
How to use GridLayout。使用什麼以及如何使用。
0
我還以爲這一小段代碼,可以幫助你出來......我做了它的淨咖啡豆,但我都談到了U中的重要組成部分....如果ü可以更具體關於「組織」,我可以幫你出來......但AFAIK..if你的意思是組織爲讓他們一組......那麼你知道它很容易將它們分組和u還可以使用一個for循環來標註全部按鍵...;)...如果有別的讓我知道......我還一直在關注許多關於layout..so輸出佈局的尺寸必須小,但我敢肯定,U可以設置其大小;)歡呼!
import java.awt.*;
import javax.swing.*;
public class GridLayoutJRB {
public final static boolean RIGHT_TO_LEFT = false;
public static void addComponentsToPane(Container contentPane) {
if (RIGHT_TO_LEFT) { // blah ! blah ! blah !
contentPane.setComponentOrientation(
ComponentOrientation.RIGHT_TO_LEFT);
}
// 3 rows and 3 columns..this is what you require here .. :)
contentPane.setLayout(new GridLayout(3,3));
contentPane.add(new JRadioButton("1"));
contentPane.add(new JRadioButton("2"));
contentPane.add(new JRadioButton("3"));
contentPane.add(new JRadioButton("4"));
contentPane.add(new JRadioButton("5"));
contentPane.add(new JRadioButton("6"));
contentPane.add(new JRadioButton("7"));
contentPane.add(new JRadioButton("8"));
contentPane.add(new JRadioButton("9"));
}
//again blah blah blah !
private static void createAndShowGUI() {
JFrame.setDefaultLookAndFeelDecorated(true);
JFrame frame = new JFrame("GridLayout With JRadio Buttons");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
//Set up the content pane and components in GridLayout
addComponentsToPane(frame.getContentPane());
frame.pack();
frame.setVisible(true);
}
public static void main(String[] args) {
javax.swing.SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
createAndShowGUI();
}
});
}
}
相關問題
- 1. 如何在JRadioButton上設置動態setIcon
- 2. 如何設置元素的位置等於另一個元素的位置?
- 3. 如何將UITableView的滾動位置設置爲ios中的上一個位置
- 4. 設置一個滾動條的位置
- 5. UIGraphicsBeginImageContext如何設置位置?
- 6. 如何設置BoundingRectangle位置
- 7. 獲取一個位的位置,如果它被設置
- 8. 機器人如何設置一個假的位置打電話
- 9. 基於JLabel設置JRadioButton爲true
- 10. 如何設置位?
- 11. 如何在JFrame的任何位置設置按鈕的位置
- 12. 設置一個位置,在PowerShell中
- 13. 一個單一的職位來設置設置
- 14. 如何設置另一個控件按比例位置
- 15. 如何創建一個新的JFrame,位置設置爲另一個JFrame的中間位置?
- 16. 在Bitset中設置一位會導致設置幾個位
- 17. 設置多個位置
- 18. 如何設置nginx.conf的「位置」
- 19. 如何設置水龍頭的位置
- 20. 如何更改Firefox的位置設置
- 21. 如何設置ASP.NET Ajax ModalPopupExtender的位置?
- 22. 如何設置QMainWindow的位置?
- 23. 如何設置在層CC3Node的位置?
- 24. 如何設置Entry Scollbar的位置?
- 25. 如何設置UIViewController標題的位置?
- 26. 我該如何設置pegman的位置?
- 27. CSS - 如何設置UL的位置LI
- 28. 如何設置UICollectionViewCell的位置?
- 29. 如何設置j按鈕的位置?
- 30. 如何設置廣播組的位置
,是的它的網格佈局:d – uLYsseus