java - An array of BufferedImage is showing null for the values set -
In class getPathGiveIcon, giving an array of strings for the getPaths () method is an array of this GetPaths () image Icon Hope to go back In this process, I am trying to create a file by name of each path in the array of strings, but there is an error on this line I Img [i] = ImageIO.read (fa); // Error in this line Please guide me to come to this error ...
Here is the full code of getPaths () method.
Public class GetPathGiveIcon {ImageIcon [iic; File f = new file (""); Int i = 0; Public Image Icon [] getPaths (string [] s) {BufferedImage [] img = null; For (string stat: s) {System.out.println (st); } (String stat: s) {{file file = new file (cents); IMG [I] = ImageOo Reed (FA); Try blocking the value of System.out.println ("every string =" + cents); }} Hold (exception e) {e.printStackTrace (); } System.out.println ("Price Before Scaling" + i); I = 0; For (Beaufred Image BI: IMG) {IICC [I] = New Image Icon (BI); Image scale = iic [i] .getImage (). GetScaledInstance (150,150, Image. SCALE_DEFAULT); Iic [i] = new imaging (scaled); I ++; } System.out.println ("I value after scaling" + i); Return iic; }}
I'm always equal to 0, so your code is just your first element Array will fill.
Here's the solution:
BufferedImage [] img = new buffard image [s.length]; (String stat: s) {try {file fa = new file (st); IMG [I ++] = ImageOo (PA); Try blocking the value of System.out.println ("every string =" + cents); } Hold (exception e) {e.printStackTrace (); }} edit iic with the same problem, it is to get started iic = new image icon [img.length]; I = 0; For (Beaufred Image BI: IMG) {IICC [I] = New Image Icon (BI); // [...]
Comments
Post a Comment