JFilechooser中的java.awt.Headless异常

JFilechooser中的java.awt.Headless异常,java,jfilechooser,Java,Jfilechooser,这段代码不断给出java.awt.HeadlessException,我不知道为什么。 我正在使用Netbeans 7.4 此代码用于在添加文件选择器之前工作。 我过去常常给出一条绝对路径。 代码: 谢谢你的回复。我的意思是“我不知道为什么”你能发布异常的stacktrace吗?我必须做些什么?谢谢回复。我的意思是“我不知道为什么”你能发布异常的stacktrace吗?我必须怎么做? JButton open = new JButton(); JFileChooser fc = new JFil

这段代码不断给出
java.awt.HeadlessException
,我不知道为什么。
我正在使用Netbeans 7.4
此代码用于在添加文件选择器之前工作。
我过去常常给出一条绝对路径。
代码:


谢谢你的回复。我的意思是“我不知道为什么”你能发布异常的stacktrace吗?我必须做些什么?谢谢回复。我的意思是“我不知道为什么”你能发布异常的stacktrace吗?我必须怎么做?
JButton open = new JButton();
JFileChooser fc = new JFileChooser();
fc.setCurrentDirectory(new java.io.File("C:\\Users\\theOPOne\\Desktop"));
fc.setDialogTitle("Choose path !");
fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
if (fc.showOpenDialog(open) == JFileChooser.APPROVE_OPTION){
   /*...*/
}

Document document=new Document(); 
PdfWriter.getInstance(document,new FileOutputStream(fc.getSelectedFile().getAbsolutePath())); 
document.open(); 
document.add(new Paragraph("Hello world this is my first PDF"));
document.close();