private void inchButtonActionPerformed(java.awt.event.ActionEvent evt) { String s = inchField.getText(); try { double inch = Double.parseDouble(s); inch = inch*100; int inch2 = (int)inch; cmField.setText(""+Harjoitus2.inchesToCm(inch)); } catch (NumberFormatException ex) { JOptionPane.showMessageDialog(this, "You must input a number", "Invalid input", JOptionPane.ERROR_MESSAGE); } }