Hallo zusammen,
ich habe vor ein Array mit ImageIcons zu füllen.
Globale Variable:
Danach der Code zum befüllen.
Das brauche ich, weil ich Labels mit den entsprechenden Bildern füllen will und das geht wohl nicht mt Files, also muss ich diese in ImageIcons umwandeln.
Wo ist das Problem, es wird kompiliert, bekomme dann aber folgende Meldung.
ich habe vor ein Array mit ImageIcons zu füllen.
Globale Variable:
Code:
ImageIcon[] pics;
Danach der Code zum befüllen.
Code:
File dir = new File( "./images" );
File[] files = dir.listFiles( new JPGFilter() );
a = new ImageIcon("./images/"+files[x++].getName());
for(int i=0; i<files.length; i++)
pics[i] = new ImageIcon(a.getImage());
Das brauche ich, weil ich Labels mit den entsprechenden Bildern füllen will und das geht wohl nicht mt Files, also muss ich diese in ImageIcons umwandeln.
Wo ist das Problem, es wird kompiliert, bekomme dann aber folgende Meldung.
Code:
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at org.eclipse.ve.internal.java.vce.launcher.remotevm.JFCLauncher$1.run(JFCLauncher.java:59)
at java.awt.event.InvocationEvent.dispatch(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)IWAV0052E Invocation Target Exception creating jFotoalbum
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
Caused by: java.lang.NullPointerException
at jFotoalbum.initialize(jFotoalbum.java:53)
at jFotoalbum.<init>(jFotoalbum.java:29)
... 13 more