我通过单击btn obt获取nullpointer异常,这是由jfilechooser抛出的nullpointerexception。不知道该怎么做这个问题" re = jf.showOpenDialog(null);" 任何人都可以请这个错误吗?
public void actionPerformed(ActionEvent e)
{
if (e.getSource()==obt)
{
try
{
int re = jf.showOpenDialog(null);
if(re==JFileChooser.APPROVE_OPTION)
{
File f=jf.getSelectedFile();
t1.append("Opening:"+f.getName()+ ".");
}
else
{
t1.append("Open command cancelled by user." );
}
t1.setCaretPosition(t1.getDocument().getLength());
}
catch(Exception ee)
{
System.out.println(ee);
}
}
else if(e.getSource()==ebt)
{
try
{
int re=jf2.showSaveDialog(null);
if(re==JFileChooser.APPROVE_OPTION)
{
File f=jf2.getSelectedFile();
t1.append("Extracting:");//+f.getName()+ ".");
}
else
{
t1.append("Extract command cancelled by user.");
}
t1.setCaretPosition(t1.getDocument().getLength());
}
catch(Exception ee)
{
System.out.println(ee);
}
}
}