So i was making an application where the user enters an input, and when he clicks the button it executes a command, however the input has to be an integer, so i added a check but even when i enter an integer is gives me an error saying "you can enter numbers only!"
heres my code :
String itemId = textField1.getText();
String itemAmount = textField2.getText();
int id = Integer.parseInt(itemId);
int amount = Integer.parseInt(itemAmount);
if (!Double.isNaN(id) || !Double.isNaN(amount)){
JOptionPane.showMessageDialog(
null, "You can only enter numbers!"
);
even after i enter numbers to the textFields i still cannot pass this test, why and how can i fix this ? thanks.