在java中运行一个swing应用程序,我在我的程序中遇到了这个异常。值得注意的是,这并不是每次我运行程序时都会出现的。
完整的堆栈跟踪:
Exception in thread "main" java.lang.ExceptionInInitializerError
at org.backend.utils.importing.Loading$1.run(Loading.java:54)
at org.backend.utils.importing.Loading.loadEverything(Loading.java:61)
at org.main.BishopCarrollSchoolTracker.main(BishopCarrollSchoolTracker.java:70)
Caused by: java.lang.ClassCastException: javax.swing.plaf.FontUIResource cannot be cast to javax.swing.InputMap
at javax.swing.plaf.basic.BasicButtonListener.getInputMap(BasicButtonListener.java:102)
at javax.swing.plaf.basic.BasicButtonListener.installKeyboardActions(BasicButtonListener.java:78)
at javax.swing.plaf.basic.BasicButtonUI.installKeyboardActions(BasicButtonUI.java:121)
at javax.swing.plaf.basic.BasicButtonUI.installUI(BasicButtonUI.java:73)
at javax.swing.JComponent.setUI(JComponent.java:662)
at javax.swing.AbstractButton.setUI(AbstractButton.java:1782)
at javax.swing.plaf.synth.SynthArrowButton.updateUI(SynthArrowButton.java:34)
at javax.swing.AbstractButton.init(AbstractButton.java:2149)
at javax.swing.JButton.<init>(JButton.java:118)
at javax.swing.JButton.<init>(JButton.java:73)
at javax.swing.plaf.synth.SynthArrowButton.<init>(SynthArrowButton.java:23)
at javax.swing.plaf.synth.SynthScrollBarUI$2.<init>(SynthScrollBarUI.java:325)
at javax.swing.plaf.synth.SynthScrollBarUI.createIncreaseButton(SynthScrollBarUI.java:325)
at javax.swing.plaf.basic.BasicScrollBarUI.installComponents(BasicScrollBarUI.java:225)
at javax.swing.plaf.basic.BasicScrollBarUI.installUI(BasicScrollBarUI.java:147)
at javax.swing.JComponent.setUI(JComponent.java:662)
at javax.swing.JScrollBar.setUI(JScrollBar.java:190)
at javax.swing.JScrollBar.updateUI(JScrollBar.java:210)
at javax.swing.JScrollBar.<init>(JScrollBar.java:144)
at javax.swing.JScrollBar.<init>(JScrollBar.java:159)
at javax.swing.JScrollPane$ScrollBar.<init>(JScrollPane.java:698)
at javax.swing.JScrollPane.createHorizontalScrollBar(JScrollPane.java:794)
at javax.swing.JScrollPane.<init>(JScrollPane.java:282)
at javax.swing.JScrollPane.<init>(JScrollPane.java:305)
at org.gui.base.generic.panels.ListTablePanel.<init>(ListTablePanel.java:44)
at org.gui.base.main.internal.WorkPanel.<init>(WorkPanel.java:28)
at org.gui.base.main.internal.InternalPanel.<clinit>(InternalPanel.java:38)
... 3 more
导致异常的行(在我的源代码中):
public static final WorkPanel WORK = new WorkPanel();
前往
super(new WorkTable(AllWork.getElements(), true, true, true, true, true, true, true),
new WorkTable(AllWork.getElements(), true, true, true, true, true, true, true, true));
到
public ListTablePanel(RefreshableTable m, RefreshableTable t) {
this.main = m;
this.totals = t;
setLayout(LayoutFactory.createLayout());
JScrollPane pane = new JScrollPane(main);
main.setAutoCreateRowSorter(false);
totals.setFont(totals.getFont().deriveFont(Font.BOLD));
totals.setEnabled(false);
pane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
add(pane, LayoutFactory.newFactory().setFill(GridBagConstraints.BOTH).
setY(0).setWeightX(1).setWeightY(1));
add(totals, LayoutFactory.newFactory().setFill(GridBagConstraints.BOTH).
setY(1).setWeightX(1).setInsets(new Insets(0, 2, 0, 17)));
}
我源代码中的最后一段代码是JScrollPane
.
我不明白为什么会抛出这个异常。