java - String to int then change background -
I need some help for my colors, so what I'm going to do, RGB color light in 3 text fields Type 255,255,0. So I have to convert them int and the last change to the background color. Now the problem is that I get some errors when I'm clicking OK button.
Public Null Action Function (ActionEvent e) {if (e.getSource () == ok) {int rgb = integer Parasont (text 1.gate text) ()); Int RGB 1 = Integer PRIIT (text 2.getText ()); Int RGB 2 = integer. ParisInt (text 3.getText ()); V.setBackground (new color (RGB, RGB1, RGB2)); } This yield: Exception in thread "AWT-EventQueue-0" java.lang.NumberFormatException: for input string: "java.lang.NumberFormatException.forInputString (unknown The logic clearly states that you are trying to convert an empty string to an integer. For the input string: "" that means you are passing
AWT-EventQueue-0 "java.lang.NumberFormatException: int color = integer.parseInt (" "); // Exception because of this. Make sure your text fields Whose pass number. , provide validation for them.
Comments
Post a Comment