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 javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel10;
private javax.swing.JLabel jLabel11;
private javax.swing.JLabel jLabel12;
private javax.swing.JLabel jLabel13;
private javax.swing.JLabel jLabel14;
private javax.swing.JLabel jLabel15;
private javax.swing.JLabel jLabel16;
private javax.swing.JLabel jLabel17;
private javax.swing.JLabel jLabel18;
private javax.swing.JLabel jLabel19;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel20;
private javax.swing.JLabel jLabel21;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JLabel jLabel5;
private javax.swing.JLabel jLabel6;
private javax.swing.JLabel jLabel7;
private javax.swing.JLabel jLabel8;
private javax.swing.JLabel jLabel9;
// End of variables declaration
}
양식이나 패널에 buttongroup을 추가 할 필요가 없습니까? –
새로운 패널과 레이블에 추가하려고 시도했지만 어떤 방법으로도 표시되지 않습니다. – dreadnightmare