简体   繁体   English

用JFrame调用JComboBox

[英]Calling JComboBox with JFrame

I´m new in creating GUI in Java, I would like to implement JComboBox (which uses GlazedLists), in my JFrame, which is in another class. 我是用Java创建GUI的新手,我想在另一个类的JFrame中实现JComboBox(使用GlazedLists)。 Is it possible to call this JComboBox in my JFrame? 是否可以在我的JFrame中调用此JComboBox? I´m asking because I use NetBeans (some parts of code are forbidden to edit). 我问是因为我使用NetBeans(某些代码部分被禁止编辑)。 Thanks 谢谢

You can access the reference to the JComboBox like any other variable. 您可以像其他任何变量一样访问对JComboBox的引用。 The name of the combo boxes variable will depend if your reamed the object or not (you can do this from the form inspector, usually found under the projects window when in design mode) 组合框变量的名称将取决于是否对对象进行扩孔(可以从窗体检查器中进行此操作,通常在设计模式下可以在项目窗口下找到该窗体)

While you can't modify the code in the protected blocks, you still effect he combo box (or any other component) within your code normally, just make sure initComponents has been called first 尽管您无法修改受保护块中的代码,但仍然可以正常执行代码中的组合框(或任何其他组件),只需确保首先调用了initComponents

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM