Hello everyone at MacRumors Forums.
I have been having trouble with a little Java project I am working on.
I have been using a Java learning environment called BlueJ to write small program, and have switched to XCode to make it a full Mac app.
My trouble is, I had an image displaying in a JFrame in BlueJ, but I can't get it working in XCode.
In my buildInterface() method (which is called in the constructor) I have this code:
ImageIcon icon = createImageIcon("money.gif", "The app title icon.");
top = new JLabel(icon);
header.add(top);
My createImageIcon method looks like this:
protected static ImageIcon createImageIcon(String path, String description) {
java.net.URL imgURL = Asset_Monitor.class.getResource(path);
if (imgURL != null) {
return new ImageIcon(path, description);
} else {
System.err.println("Couldn't find file: " + path);
return null;
}
}
The "money.gif" image file is located in the root directory of the project.
As I said it displays fine in BlueJ but I can't get it working in XCode.
Any help would be greatly appreciated.
I have been having trouble with a little Java project I am working on.
I have been using a Java learning environment called BlueJ to write small program, and have switched to XCode to make it a full Mac app.
My trouble is, I had an image displaying in a JFrame in BlueJ, but I can't get it working in XCode.
In my buildInterface() method (which is called in the constructor) I have this code:
ImageIcon icon = createImageIcon("money.gif", "The app title icon.");
top = new JLabel(icon);
header.add(top);
My createImageIcon method looks like this:
protected static ImageIcon createImageIcon(String path, String description) {
java.net.URL imgURL = Asset_Monitor.class.getResource(path);
if (imgURL != null) {
return new ImageIcon(path, description);
} else {
System.err.println("Couldn't find file: " + path);
return null;
}
}
The "money.gif" image file is located in the root directory of the project.
As I said it displays fine in BlueJ but I can't get it working in XCode.
Any help would be greatly appreciated.