按详细信息单击排序/显示的例外[showopendialog] [JFileChooser]

时间:2014-03-12 13:34:12

标签: java eclipse exception show jfilechooser

这只是一个例子:

import javax.swing.JFileChooser;

public class Asgfsa {



    private JFileChooser fc;

    public Asgfsa(){
        fc = new JFileChooser();
        fc.showOpenDialog(null);
    }

    public static void main(String[] args) {

        Asgfsa b = new Asgfsa();

    }

}

发生的情况:

  

事件调度期间发生异常:   java.lang.ArrayIndexOutOfBoundsException:数组索引超出范围:0       在java.util.Vector.elementAt(Vector.java:333)       在javax.swing.table.DefaultTableColumnModel.getColumn(DefaultTableColumnModel.java:288)       at sun.swing.FilePane.fixNameColumnWidth(FilePane.java:1143)       在sun.swing.FilePane.access $ 2300(FilePane.java:46)       at sun.swing.FilePane $ 6.componentResized(FilePane.java:1076)       at java.awt.Component.processComponentEvent(Component.java:5971)       at java.awt.Component.processEvent(Component.java:5925)       at java.awt.Container.processEvent(Container.java:2034)       at java.awt.Component.dispatchEventImpl(Component.java:4512)       at java.awt.Container.dispatchEventImpl(Container.java:2092)       at java.awt.Component.dispatchEvent(Component.java:4342)       在java.awt.EventQueue.dispatchEvent(EventQueue.java:610)       at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:280)       at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:195)       at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:189)       在java.awt.Dialog $ 1.run(Dialog.java:1058)       at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:220)       at java.awt.EventQueue.dispatchEvent(EventQueue.java:608)       at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:280)       at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:195)       at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:185)       at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:180)       at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:172)       在java.awt.EventDispatchThread.run(EventDispatchThread.java:133)

1 个答案:

答案 0 :(得分:0)

在打开对话框之前,将FileFilter(使用setFileFilter()方法)添加到对话框中。