如何将复选框 [组合框] 列表添加到 Java Netbeans Swing 应用程序中的 JScrollPane
我有一个名称和关联值的列表来创建复选框,例如
["SAMABULA","CARPETS INTERNATIONAL","HRM/TRAINING"]
["091","094","003"]
如何使用这些值创建复选框将这些复选框添加到 Netbeans IDE 中的 JScrollPane 中。
这是一个 Swing 应用程序。我从调色板创建了一个窗口,并将 jscrollpane 添加到该窗口。但我不知道如何将复选框列表添加到该滚动窗格。
I have a list of names and associated values to create checkboxes like
["SAMABULA","CARPETS INTERNATIONAL","HRM/TRAINING"]
["091","094","003"]
How to create checkboxes with these values add these checkboxes to JScrollPane in Netbeans IDE.
This is a Swing application. I created a window from palette and added jscrollpane to that window. But I don't know how to add list of checkboxes to that scrollpane.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
@ Srikanth Dyapa
您已经有两个区域
JList 其中包含JCheckBox(es)
然后你只需声明
或者你必须将您的 JCheckBox 到 JList 或 JPanel 但对于具有正确 LayoutManager 例如 GridLaoyut
如上所述
然后将您的 JList 或 JPanel 添加到 JScrollPane 中,可能 ButtonGroup 组件 可以帮助您
@ Srikanth Dyapa
there are two areas
you have already JList that's contains JCheckBox(es)
then you just declare
or you have to put your JCheckBox to JList or JPanel but for JPanel with correct LayoutManager for example GridLaoyut
thenarter add your JList or JPanel to the JScrollPane as is above mentioned
maybe ButtonGroup Component can help you with that
当我使用 Eclipse 时,不确定如何将它们添加到 NetBeans 中,但代码类似于:
请参阅此处了解更多详细信息和示例:http://download.oracle.com/javase/tutorial/uiswing/components/scrollpane.html
Not sure how to add them in NetBeans as i use Eclipse, but in code would be something like:
see here for more detail and examples: http://download.oracle.com/javase/tutorial/uiswing/components/scrollpane.html
在 Netbeans 中,您只需将复选框拖放到需要的位置即可。在操作监听器中,您可以使用
jCheckBox1.isSelected()
来检查用户是否选中了该框。In Netbeans you just drag and drop the Check Boxes where you need them. In an Action Listener you use
jCheckBox1.isSelected()
in order to check if the user has checked the box or not.