如何在Eclipse中使用MiG Layout?

时间:2023-01-20 17:13:07

I've been Googling and checking on Stack Overflow and nothing has helped... hopefully someone can.

我一直在谷歌搜索和检查Stack Overflow并没有任何帮助...希望有人可以。

I usually just write my code by hand, but I'm working on a Java project that has a GUI aspect and I like what MiG Layout has to offer so I want to use it. I've downloaded the .jar file from the website, but I can't seem to be able to access it from my project.

我通常只是手工编写代码,但我正在开发一个具有GUI方面的Java项目,我喜欢MiG Layout提供的代码,所以我想使用它。我从网站上下载了.jar文件,但似乎无法从我的项目中访问它。

I'm using Eclipse now as my IDE for this project because I don't want to have to deal with this particular thing by hand. I'm new to Eclipse, but here's what I've been trying: import the .jar file (via the Import tool for the project), then add the following code to my files:

我现在使用Eclipse作为此项目的IDE,因为我不想手动处理这个特定的事情。我是Eclipse的新手,但这是我一直在尝试的:导入.jar文件(通过项目的导入工具),然后将以下代码添加到我的文件中:

import net.miginfocom.swing.MigLayout;
import javax.swing.*;

According to this page, this should work, right?

根据这个页面,这应该工作,对吧?

But when I try to run the program, I'm met with this message:

但是当我尝试运行程序时,我遇到了这样的消息:

Exception in thread "main" java.lang.Error: Unresolved compilation problem: 
    MigLayout cannot be resolved to a type

What am I doing wrong?

我究竟做错了什么?

1 个解决方案

#1


It sounds like the "import tool" part didn't work properly - that Eclipse isn't actually using the jar file.

听起来“导入工具”部分无法正常工作 - Eclipse实际上并没有使用jar文件。

I suggest you right-click on the project, choose Properties, and go to the Build Path page. Look under the "Libraries" tab. Assuming the jar file isn't there, add it and all should be well.

我建议你右键单击该项目,选择Properties,然后转到Build Path页面。查看“库”选项卡下的内容。假设jar文件不存在,添加它,一切都应该没问题。

#1


It sounds like the "import tool" part didn't work properly - that Eclipse isn't actually using the jar file.

听起来“导入工具”部分无法正常工作 - Eclipse实际上并没有使用jar文件。

I suggest you right-click on the project, choose Properties, and go to the Build Path page. Look under the "Libraries" tab. Assuming the jar file isn't there, add it and all should be well.

我建议你右键单击该项目,选择Properties,然后转到Build Path页面。查看“库”选项卡下的内容。假设jar文件不存在,添加它,一切都应该没问题。