I have an paneel.java file wich looks like the following code:
import java.awt.*;
import javax.swing.*;
public class Paneel extends JFrame
{
public stat
public static void main ( String [] args )
{
// frame
JFrame frame = new Paneel();
frame.setSize ( 1000, 1000 );
frame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
frame.setTitle( "Remembory" );
// Add following
GifPaneel gifpan = new GifPaneel();
gifpan.repaint();
frame.add(gifpan);
frame.setVisible( true );
}
you need to set a file path to the image..something like this
final ImageIcon icon = new ImageIcon("C:\\Users\\you\\Desktop\\test.gif");
Use this
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import javax.imageio.ImageIO;
import javax.swing.*;
public class ImageInFrame {
public static void main(String[] args) throws IOException {
String path = "Image1.jpg";
File file = new File(path);
BufferedImage image = ImageIO.read(file);
JLabel label = new JLabel(new ImageIcon(image));
JFrame f = new JFrame();
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.getContentPane().add(label);
f.pack();
f.setLocation(200,200);
f.setVisible(true);
}
}
create package named as images on your project file and import image in that perticular package. Now, take a lable and select the icon property and select image from class path.