Java 在 Netbeans 中导入 org-jdesktop-layout
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/14094566/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Java Importing org-jdesktop-layout in Netbeans
提问by CodeKingPlusPlus
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 Files\NetBeans 7.0.1\platform\modules
我已将 org-jdesktop-layout.jar 添加到我项目中 netbeans 的库中。我在以下位置找到了这个 .jar 文件:C:\Program Files\NetBeans 7.0.1\platform\modules
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?
我想我缺少正确的导入语句。什么是正确的导入语句?如果还有其他有用的信息,请告诉我!还有什么决定了导入语句的前缀?
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?
编辑:以下代码似乎来自较旧的 GUI 库。我有两个选择,转换为更新的 GUI 标准或访问旧的 GUI 标准?我以前从未做过这样的事情。我能做什么?
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
我认为这可能是一个较旧的图书馆......提前致谢
回答by Catalina Island
You have to import the library class you want,
你必须导入你想要的库类,
import org.jdesktop.layout.GroupLayout;
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.
但您还必须右键单击项目的Libaries
节点,选择Add Library…
并选择Swing Layout Extensions
。它应该已经在那里等待了。