您的位置:首页 > 编程语言 > Java开发

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);

                                            
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: