I have JOptionPane which asks the user for a String, I wanna be able to restrict the user to input any spacebars, any suggestions?
String firstNumber;
firstNumber = JOptionPane.showInputDialog ( "Enter file name" );
You mean you want to disallow the ability for the user to input spaces?
There are more complex ways, but the easiest would to just remove all spaces from the string after you get it back.
firstNumber = firstNumber.replaceAll(" ","");
If the length after this is 0, then you can just prompt them again.