JFileChooser에서 노래 목록을 선택한 후 오디오 정보를 jList에 표시하고 싶습니다. 여기까지 내가 얻은 것이 있는데, 그것은 NullPointerException
을 던졌습니다. jList에 오디오 정보를 표시하는 방법
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at SoundsTrip.SoundBytePlaying.openFile(SoundBytePlaying.java:267)
at SoundsTrip.SoundBytePlaying.jButton1MouseClicked(SoundBytePlaying.java:210)
at SoundsTrip.SoundBytePlaying.access$000(SoundBytePlaying.java:43)
at SoundsTrip.SoundBytePlaying$2.mouseClicked(SoundBytePlaying.java:135)
at java.awt.AWTEventMulticaster.mouseClicked(AWTEventMulticaster.java:253)
at java.awt.Component.processMouseEvent(Component.java:6270)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3267)
at java.awt.Component.processEvent(Component.java:6032)
at java.awt.Container.processEvent(Container.java:2041)
at java.awt.Component.dispatchEventImpl(Component.java:4630)
at java.awt.Container.dispatchEventImpl(Container.java:2099)
at java.awt.Component.dispatchEvent(Component.java:4460)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4577)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4247)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4168)
at java.awt.Container.dispatchEventImpl(Container.java:2085)
at java.awt.Window.dispatchEventImpl(Window.java:2478)
at java.awt.Component.dispatchEvent(Component.java:4460)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:599)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)
방법이 발생하고 어떻게 그것을 해결할 수 :
boolean openFile() throws FileNotFoundException{
JFileChooser jfc = new JFileChooser();
jfc.setMultiSelectionEnabled(true);
jfc.setDialogTitle("Open File");
jfc.setFileSelectionMode(JFileChooser.FILES_ONLY);
jfc.setCurrentDirectory(new File ("."));
jfc.setFileFilter(audiofilter);
int result = jfc.showOpenDialog(this);
if(result == JFileChooser.CANCEL_OPTION){
return true;
}else if(result == JFileChooser.APPROVE_OPTION){
File[] file = jfc.getSelectedFiles();//fFile = jfc.getSelectedFile();
String file_string = fFile.getAbsolutePath();
for(int i=0;i<file.length;i++){
if(file[i].isFile()){
String[] filesInDirectory = file[i].list();
for(int ii=0;ii<filesInDirectory.length;ii++){
list.addElement(filesInDirectory[ii]);
}
}else{
list.addElement(file[i]);
}
}
if(file_string != null){
fTextArea.setText(file_string);
}else{
return false;
}
this.jList1.setModel(list);
}
return true;
}
오류는 말한다?
도움을 청하는 필요가 없습니다. 누구나 동등하게 여기에서 도움을 얻습니다. 그냥 똑똑한 방식으로 질문하십시오. 나는 조금 질문을 청소했다. – BalusC
감사합니다 ... 다음 번에 ....... –
및 267 호선은 · ·? – draganstankovic