You must know how to fetch data from the database since you say you know how to get the answers from the database, so let's assume you've retrieved a question that you want to apply to your radio button. We'll call it myQuestion
.
JRadioButton has a constructor which takes a String and a boolean as arguments, representing the String that the radio button should be displayed, and whether the radio button should be selected.
JRadioButton myRadioButton = new JRadioButton(myQuestion, false);
This gives you an unselected radio button with your question as text.
Now what if you want to change your question at some point? You can use JRadioButton's setText() method to change the radio button's text at any time.
myRadioButton.setText(myNewQuestion);
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…