设置选定的单选按钮 - NetBeans Swing

时间:2014-11-16 04:59:00

标签: java swing netbeans radio-button

if(DishFormWeekNoWeek1Rb.hasFocus() == true){
    DishFormWeekNoWeek1Rb.setSelected(hasFocus());
    System.out.print(DishFormWeekNoWeek1Rb.getComponents().getClass().toString());
}

如何改进上面的代码,以便在单选按钮聚焦时它也会被选中?因为我正在使用标签转到下一个单选按钮,我想要的是当我选择并专注于单选按钮时,它也将被选中。鉴于意见和建议表示赞赏。

1 个答案:

答案 0 :(得分:0)

if(DishFormWeekNoWeek1Rb.hasFocus() == true){

            DishFormWeekNoWeek1Rb.setSelected(true);
            DishFormWeekNoWeek1Rb.requestFocus(true);
            System.out.print(DishFormWeekNoWeek1Rb.getComponents().getClass().toString());
        } 

@Andrew请对这个正在运行的评论发表评论也许你可以批评它是否有一个循环漏洞