为什么这个 SSCCE(带有 MigLayout 库)......
public static void main(String[] args) {
try {
UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
} catch (ClassNotFoundException | InstantiationException | IllegalAccessException | UnsupportedLookAndFeelException e) {
e.printStackTrace();
}
JFrame frame = new JFrame();
frame.setLayout(new MigLayout(new LC().fill().insetsAll("0")));
JTabbedPane jtp = new JTabbedPane();
jtp.add(new JPanel(), "Tab 1");
jtp.add(new JPanel(), "Tab 2");
JLabel label = new JLabel("label");
JPanel panel = new JPanel(new MigLayout(new LC().fill()));
panel.add(jtp, "id tabbedpane, grow, span");
panel.add(label, "pos (tabbedpane.w-label.w) 10, id label");
label.setBounds(100, 100, 10, 10);
frame.add(panel, "grow, span");
frame.setSize(500, 500);
frame.setLocationRelativeTo(null); // Sorry, Andrew Thompson
frame.setVisible(true);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
抛出这个错误:
Unstable cyclic dependency in absolute linked values!
Unstable cyclic dependency in absolute linked values!
Unstable cyclic dependency in absolute linked values!
Unstable cyclic dependency in absolute linked values!
?
我发现如果你删除WindowsLookAndFeel
代码,然后一切运行正常......
所以,这是 MigLayout 和WindowsLookAndFeel
。然而我的实际应用需要使用它。
EDIT:
这是抛出错误时的框架的样子: