将 JRadioButton 添加到 RadioButton 组
美好的一天
想知道如何通过将组件拖放到框架上来将单选按钮添加到 ButtonGroup 中。
JRadioButton male = new JRadioButton("Male");
JRadioButton female = new JRadioButton("Female");
ButtonGroup bg = new ButtonGroup();
bg.add(male);
bg.add(female);
pane.add(male);
pane.add(female);
我怎样才能通过简单的拖放来做到这一点。如果我将 ButtonGroup 放到框架上,它将被分组在“其他组件”下,从那里我不确定如何将单选按钮添加到按钮组。
谢谢 问候阿里安
Good day
Would like to know how to add radiobuttons to a ButtonGroup by dragging and dropping components on to the frame.
JRadioButton male = new JRadioButton("Male");
JRadioButton female = new JRadioButton("Female");
ButtonGroup bg = new ButtonGroup();
bg.add(male);
bg.add(female);
pane.add(male);
pane.add(female);
How can I do this by simple dragging and dropping. If I drop the ButtonGroup onto the frame it gets grouped under 'other components' and from there I am not exactly sure how to add radio buttons to the button group.
thanks
regards Arian
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您已经查看了 HierarchyListener,
hierarchyChanged
事件,您已将新的JRadioButton
添加到ButtonGroup
中,仔细了解最后知道的具体 isSelectedJRadioButton
you have look at HierarchyListener, on
hierarchyChanged
event you have add a newJRadioButton
to theButtonGroup
, carefully with last know isSelected for concreteJRadioButton