我想在java中进行调查.我有20个问题和5个可能的选择.我想要制作20个标签和100个按钮组合5个.
我设法使用Net beans GUI手动添加标签,但我想生成按钮,但它们没有显示.这是我的代码:
public class Prikaz extends javax.swing.JFrame {
/**
* Creates new form Prikaz
*/
public Prikaz() {
initComponents();
javax.swing.JRadioButton [][] buttons = new javax.swing.JRadioButton [20][5];
ButtonGroup [] bg = new ButtonGroup[20];
for (int i = 0; i < 20; ++i) {
bg[i]= new ButtonGroup();
for (int j = 0; j < 5; ++j) {
buttons[i][j] = new javax.swing.JRadioButton();
if(j==0)buttons[i][j].setSelected(true);
buttons[i][j].setLocation(1014+(j*24) , 44+(i*31));
buttons[i][j].setToolTipText(((Integer)(j+1)).toString());
buttons[i][j].setVisible(true);
buttons[i][j].setEnabled(true);
bg[i].add(buttons[i][j]);
}
}
}
// Variables declaration - do not modify
private …Run Code Online (Sandbox Code Playgroud)