【发布时间】:2017-03-13 05:10:58
【问题描述】:
I have one JInternalframe in which there are many JRadioButton and JLabel. I want to Retrive Data from Database and display on this JRadioButton and JLabel
由于数据库中可以有任意数量的行将被获取。
我已成功从数据库中获取数据,但无法在 JRadioButton 和 JLabel 上设置它
void setData(String s1, String s2, String s3, int cnt) {
//Setting JRadioButton and JLabel Coding Part Here
}
在变量 s1,s2,s3 中的上述函数中存在我想要显示的数据,并且在变量 cnt 中有计数器的值在 resultset.next 上递增( )
谁能给我一些关于如何在 JRadiobutton 和 JLabel 上显示数据的提示
JRadioButton Variale 名称类似于 BT1,BT2,BT3... 所以我尝试了
【问题讨论】:
-
正如你在问题标题中所说的那样。假设您的
JRadioButton的引用是btn,只需调用btn.setText(s1)。JLabel确实有一个公共的setText方法,JRadioButton从AbstractButton继承它。 -
感谢您的建议,但如果提取的记录超过 1 条,我想将其显示在单独的 JRadioButton 和 JLabel 中,因此每次变量名称都会不同。例如,如果提取了 2 条记录所以数据应该显示在 BT1 和 BT2 等请参阅附件截图了解更多详情
标签: java variables dynamic jlabel jradiobutton