항목이 선택 될 때마다 ActionListener를 사용하여 JList를 업데이트하고 있습니다.예외가 JList의 업데이트를 죽이는 것 같습니다
jComboBox.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
JComboBox cb = (JComboBox) e.getSource();
updateLocalFileList(cb.getSelectedItem().toString());
}
});
UI 용으로이 메서드를 호출하고 있습니다.
getFileListFromDirectory는()는 NullPointerException를 제공하는 경우public void updateLocalFileList(String path){
DefaultListModel model = new DefaultListModel();
for (String str : LocalFileSystem.getFileListFromDirectory(path)) {
model.addElement(str);
}
getJList().setModel(model);
}
는 빈 DVD 드라이브의 문자를 선택하면 말은 의도 한대로 작업에서 ActionListener를 방지하기 위해 보인다.
정확히 무슨 일이 일어나는 지 모르겠지만 모델에 null 값을 전달하면이 문제가 발생한다고 생각됩니다.
아이디어가 있으십니까? 요청에 따라
편집 여기
는 스택 트레이스입니다. 보시다시피이 메서드는 탐색 할 수없는 드라이브에서 NullPointerException을 유발합니다. 나는 JList를 업데이트하지 못하게하는 이유는 정확히 알지 못한다.
java.lang.NullPointerException
at mine.View.updateLocalFileList(View.java:274)
at mine.View$1.actionPerformed(View.java:262)
at javax.swing.JComboBox.fireActionEvent(Unknown Source)
at javax.swing.JComboBox.setSelectedItem(Unknown Source)
at javax.swing.JComboBox.setSelectedIndex(Unknown Source)
at javax.swing.plaf.basic.BasicComboPopup$Handler.mouseReleased(Unknown Source)
at java.awt.AWTEventMulticaster.mouseReleased(Unknown Source)
at java.awt.Component.processMouseEvent(Unknown Source)
at javax.swing.JComponent.processMouseEvent(Unknown Source)
at javax.swing.plaf.basic.BasicComboPopup$1.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
stacktrace 붙여 넣기 – OscarRyz
이것이 정확히 어떤 일인지는 모르겠지만이 답변을 통해 스택 추적 (stacktrace)을 읽는 방법을 알아 봅니다. (그리고 그것이 무엇일까요?) http://stackoverflow.com/questions/3066253/java-boxes-mask-not-working/3066299 # 3066299 – OscarRyz
@Support 링크를 포함 시켰습니까? –