load image with ImageIcon component
Hello,
I want to load an image whose name or path contains special character such as accents (a french name). So that generates an exception. For exemple for an image named caf.jpeg I obtain this message :
java.io.FileNotFoundException: /media/disk/images/caf.jpeg (No such file or directory)
Can you please help me.
Thanks in advance.
# 1
hi,
get this sample example and develop
import javax.swing.*;
import javax.swing.event.*;
import javax.swing.ImageIcon;
import java.io.*;
import java.awt.*;
import java.awt.event.*;
public class ji extends JApplet
{
public Icon pulicon;
public JButton b1;
public void init()
{
getContentPane().setLayout(null);
this.setSize(744, 536);
pulicon = new ImageIcon(getImage(getCodeBase(),"bullet.gif"));
b1 = new JButton(pulicon);
getContentPane().add(b1);
b1.setBounds(50,50,42,42);
}
}
//<applet code="ji.class" height="200" width="200"></applet>
that gif picture from current dir, where your class file stores.. if u want specify the path there
# 2
This has nothing to do with JSF.
Anyway, you've clearly a charset encoding problem. Set the charset encoding right according to your locale. UTF-8 might be sufficient.