Java Swing Synth - JRadioButton Style
2016-01-13 23:07
429 查看
<pre name="code" class="plain">
<style id="radioButton"> <imageIcon id="radio_off" path="images/radio_button_off.png"/> <imageIcon id="radio_on" path="images/radio_button_on.png"/> <property key="RadioButton.icon" value="radio_off"/> <state value="SELECTED"> <property key="RadioButton.icon" value="radio_on"/> </state> </style> <bind style="radioButton" type="region" key="RadioButton"/> <style id="checkBox"> <imageIcon id="checkbox_off" path="images/checkbox_off.png"/> <imageIcon id="checkbox_on" path="images/checkbox_on.png"/> <property key="CheckBox.icon" value="checkbox_off"/> <state value="SELECTED"> <property key="CheckBox.icon" value="checkbox_on"/> </state> </style> <bind style="checkBox" type="region" key="CheckBox"/>
// JRadioButton test ButtonGroup sexGroup = new ButtonGroup(); JRadioButton boy = new JRadioButton("男", true); JRadioButton girl = new JRadioButton("女"); sexGroup.add(boy); sexGroup.add(girl); JPanel sexPanel = new JPanel(); sexPanel.add(boy); sexPanel.add(girl); this.add(sexPanel); JCheckBox football = new JCheckBox("足球"); JCheckBox basketball = new JCheckBox("篮球"); JCheckBox biker = new JCheckBox("骑行"); JPanel hobbyPanel = new JPanel(); hobbyPanel.add(football); hobbyPanel.add(basketball); hobbyPanel.add(biker); this.add(hobbyPanel);
相关文章推荐
- Java学习----集合函数
- E299:Bulls and Cows(字符串处理)
- Java学习----Math函数
- JDK的一些命令行工具
- Generating project in Batch mode 很慢的问题
- JAVA多线程互斥同步例子
- Spring Data JPA入门
- Java学习----日期函数
- Java SE 学习 chapter1
- java异常处理<2>__笔记(18)
- IntelliJ IDEA 打开eclipse工程报非法字符处理
- 运维基础-windows下安装jdk
- 运维基础-windows下安装jdk
- Java:利用java Timer类实现定时执行任务的功能
- SpringMVC 使用JSR-303进行校验 @Valid
- C#与Java的比较
- Java线程:概念与原理
- SpringMVC响应Restful风格请求404
- myeclipse的配置
- Java RMI 简介及其优劣势总结