我想使用MigLayout,然后按照以下步骤在Eclipse IDE中导入jar文件(
我认为问题不在我的代码中,但让我在这里写下。
package learning;
import javax.swing.*;
import net.miginfocom.swing.MigLayout;
public class RegistrationWindow extends JFrame {
public RegistrationWindow() {
setSize(200,200);
setTitle("User registration");
setLocationRelativeTo(null);
setResizable(true);
JPanel panel = new JPanel();
JLabel fName = new JLabel("First name ");
JLabel lName = new JLabel("Last name ");
JTextField field1 = new JTextField();
JTextField field2 = new JTextField();
panel.setLayout(new MigLayout());
panel.add(fName);
panel.add(field1);
panel.add(lName);
panel.add(field2);
}
}
我得到的错误是
Error:
Exception in thread "main" java.lang.NoClassDefFoundError: net/miginfocom/swing/MigLayout
at learning.RegistrationWindow.<init>(RegistrationWindow.java:10)
at learning.Registration.main(Registration.java:8)
Caused by: java.lang.ClassNotFoundException: net.miginfocom.swing.MigLayout
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:583)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
... 2 more
我在这里想念什么?