0
100個のJToggleButtonを作成してforループを使ってリンクリストに保存したいとします。その後、それらをグリッドバッグのレイアウトで表示します。For JToggleButtons For For
ArrayList<JToggleButton> buttons = new ArrayList<JToggleButton>();
for(int i=0; i<100; i++){
buttons.add(new JToggleButton(""));// = new JToggleButton("");
GridBagConstraints gbc_ = new GridBagConstraints();
gbc_tglbtnNewToggleButton.fill = GridBagConstraints.VERTICAL;
gbc_tglbtnNewToggleButton.insets = new Insets(0, 0, 5, 5);
gbc_tglbtnNewToggleButton.gridx = i;
gbc_tglbtnNewToggleButton.gridy = j;
frame.getContentPane().add(tglbtnNewToggleButton, gbc_tglbtnNewToggleButton);
}
私はそれを試しましたが、できません。
正解+1 – mKorbel