gpt4 book ai didi

Java:在 MetalFileChooserUI$IndentIcon.getIconWidth 中防止 NPE?

转载 作者:塔克拉玛干 更新时间:2023-11-02 19:43:18 25 4
gpt4 key购买 nike

在 Windows 系统上。我通过 FileChooser 获得了以下 NPE。这是 sun 尚未修复的已知错误。 http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6342301

有人知道防止此异常的解决方法吗?

谢谢。安德烈

Exception in thread "AWT-EventQueue-2" java.lang.NullPointerException at javax.swing.plaf.metal.MetalFileChooserUI$IndentIcon.getIconWidth(Unknown Source) at javax.swing.SwingUtilities.layoutCompoundLabelImpl(Unknown Source) at javax.swing.SwingUtilities.layoutCompoundLabel(Unknown Source) at javax.swing.plaf.basic.BasicLabelUI.layoutCL(Unknown Source) at javax.swing.plaf.basic.BasicLabelUI.getPreferredSize(Unknown Source) at javax.swing.JComponent.getPreferredSize(Unknown Source) at javax.swing.plaf.basic.BasicListUI.updateLayoutState(Unknown Source) at javax.swing.plaf.basic.BasicListUI.maybeUpdateLayoutState(Unknown Source) at javax.swing.plaf.basic.BasicListUI$Handler.valueChanged(Unknown Source) at javax.swing.DefaultListSelectionModel.fireValueChanged(Unknown Source) at javax.swing.DefaultListSelectionModel.fireValueChanged(Unknown Source) at javax.swing.DefaultListSelectionModel.fireValueChanged(Unknown Source) at javax.swing.DefaultListSelectionModel.changeSelection(Unknown Source) at javax.swing.DefaultListSelectionModel.changeSelection(Unknown Source) at javax.swing.DefaultListSelectionModel.setSelectionInterval(Unknown Source) at javax.swing.JList.setSelectedIndex(Unknown Source) at javax.swing.plaf.basic.BasicComboPopup.setListSelection(Unknown Source) at javax.swing.plaf.basic.BasicComboPopup.access$300(Unknown Source) at javax.swing.plaf.basic.BasicComboPopup$Handler.itemStateChanged(Unknown Source) at javax.swing.JComboBox.fireItemStateChanged(Unknown Source) at javax.swing.JComboBox.selectedItemChanged(Unknown Source) at javax.swing.JComboBox.contentsChanged(Unknown Source)

最佳答案

在您链接到的错误报告中,他们还提到了一种解决方法。它似乎归结为以特定顺序调用方法。你试过吗?

A DESCRIPTION OF THE PROBLEM : There appears to be an undocumented bad intereaction between explicitely setting the UI and removing all file filters, even temporarily. If the latter is done before setting the ui, trying to display a file dialog will throw an exception but not if the ui was set prior to messing with the filters. Maybe it is possible to make the code more robust against this or to include a warning in the docs?

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM : Run the attached program: it will not bomb. Then move the setUI line to the bottom of the constructor and try again: it will.

关于Java:在 MetalFileChooserUI$IndentIcon.getIconWidth 中防止 NPE?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/100343/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com