Java 在 Netbeans 中导入 org-jdesktop-layout [英] Java Importing org-jdesktop-layout in Netbeans
问题描述
我已将 org-jdesktop-layout.jar 添加到我项目的 netbeans 中的库中.我在以下位置找到了这个 .jar 文件:C:Program FilesNetBeans 7.0.1platformmodules
I have added the org-jdesktop-layout.jar to my libraries in my netbeans in my project. I found this .jar file in: C:Program FilesNetBeans 7.0.1platformmodules
但是仍然无法识别以下代码行:
However the following line of code is still not recognized:
org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
我想我缺少正确的导入语句.什么是正确的导入语句?如果还有其他有用的信息,请告诉我!还有什么决定了导入语句的前缀?
I think I am missing the right import statement. What is the right import statement? If there is any other information that would be useful, let me know! Also what determines the prefix for an import statement?
编辑:以下代码似乎来自较旧的 GUI 库.我有两个选择,转换为更新的 GUI 标准或访问旧的 GUI 标准?我以前从未做过这样的事情.我能做什么?
EDIT: The following code seems to be from an older GUI library. I have two options, convert to newer GUI standards or access old GUI standards? I have never done anything like this before. What can I do?
org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(layout.createSequentialGroup()
.addContainerGap()
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
.add(jButton1)
.add(layout.createSequentialGroup()
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(jLabel1)
.add(jLabel2))
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(layout.createSequentialGroup()
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(capFormattedTextField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 69, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
.add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(wtFormattedTextField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 69, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))))
.addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
我认为这可能是一个较旧的图书馆...提前致谢
I think this might be an older library... Thanks in advance
推荐答案
你要导入你想要的库类,
You have to import the library class you want,
import org.jdesktop.layout.GroupLayout;
但您还必须右键单击项目的Libaries
节点,选择Add Library...
并选择Swing Layout Extensions
.它应该已经在那里等待了.
but you also have to right-click on the project's Libaries
node, choose Add Library…
and select Swing Layout Extensions
. It should already be there waiting.
这篇关于Java 在 Netbeans 中导入 org-jdesktop-layout的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!