getResources() für die ImageIcon - java

meine erste Frage:

Ich habe versucht, dies herauszufinden, für ein paar Tage, aber ich kam zu dem Punkt, verlor ich meine Geduld.
Im folgenden sind einige code und meine Projekt-Struktur.

FRAGE: wie bekomme ich getResources() arbeiten in eclipse und nach importierten jar?

Danke für die Hilfe.

public enum Icons {
    XXX("src/resoruces/icons/xyz.png");
    private ImageIcon icon;
    Icons(String path) {
       try {
           //will fail miserably in eclipse and after exporting to jar
           URL imageURL = getClass().getClassLoader().getResource(path);
           icon = new ImageIcon(imageURL);
       } catch (Exception e) {
           //works like a char in eclipse and after creating the jar file
           //with the files in the same directory
           System.out.println("getResoruce() did not work");
           icon = new ImageIcon(path);
       }
   }

getResources() für die ImageIcon - java

InformationsquelleAutor Fer | 2012-12-31

Schreibe einen Kommentar