I am getting nullpointer exception by clicking on btn obt which is nullpointerexception thrown by jfilechooser. Don't know what to do for this problem "re=jf.showOpenDialog(null);" Can anyone please salve this error?
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);
}
}
}