使用JRadioButton 示例


代碼如下:

JRadioButton useCache=new JRadioButton("Use cache");// 初始化單選框
useCache.setFont(new Font("Arial",Font.PLAIN,16));// 設置字體
JRadioButton noUseCache=new JRadioButton("No cache used");
noUseCache.setFont(new Font("Arial",Font.PLAIN,16));

ButtonGroup bg=new ButtonGroup();// 初始化按鈕組
bg.add(useCache);// 加入按鈕組
bg.add(noUseCache);// 加入按鈕組

noUseCache.setSelected(true);// 選擇

useCache.isSelected();// 獲取radiobutton的選擇狀態

效果如下:


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM