A simple example
import java.awt.*;
import javax.swing.*;
import java.net.*;
public class Fred204 extends JPanel
{
public Fred204() throws Exception
{
super(new BorderLayout());
setPreferredSize(new Dimension(100,100));
}
public static void main(String[] args) throws Exception
{
JFrame frame = new JFrame("Fred204");
URL imageURL = Fred204.class.getResource("your_gif.gif");
ImageIcon imageIcon = new ImageIcon(imageURL);
frame.setIconImage(imageIcon.getImage());
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setContentPane(new Fred204());
frame.pack();
frame.setVisible(true);
}
}
This assumes that your_gif.gif is in the same directory as the class file Fred204.class .
Thanks tjacobs01. This pointed me in the right direction. My image was not loading as it resided in the same directory as the .class file. As this class was created as part of a Project, the image needed to reside in the directory for the Project and not the .class. When calling the .class from Delphi through JNI, the image needs to be in the directory of the Delphi program.
But, thanks, this got me looking in the right direction.
Regards
Rene
Message was edited by:
Rene-K