Looking at JOptionPane.showInputDialog() javadoc, this method returns a String
:
public static String showInputDialog(Component parentComponent,
Object message,
String title,
int messageType)
If Cancel button is pressed it will return null
so you get an exception trying to parse null
as an Integer
. You should do this check instead:
String value = JOptionPane.showInputDialog(this,"Capture File Name","Mandatory Filed",JOptionPane.ERROR_MESSAGE);
if(value == null) {
// Cancel button was pressed, not value returned do whataver you need to do
}