i'd like to show a .jpg file in a label, but the follow code doesn't work, the label doesn't show the "1.jpg". then i tried another .jpg file(2.jpg), it works correctly... the difference between the two .jpg file is:
"1.jpg" is a file that i created using mspaint.exe
"2.jpg" is a file downloaded from the internet
i dont know whats the difference. how could it be the matter? does it mean i cannot use the "jpg" created by myself? (windows XP , jdk 1.42) Thanks in advance !
// the code:
import java.awt.*; import javax.swing.*;
class Test extends JFrame {
ImageIcon image = new ImageIcon("1.jpg"); JPanel p = new JPanel(); JLabel lbl = new JLabel();
I tried ur programme by making a .jpg file by ms paint and it worked fine.
But here is thing i did next.
I tried creating an image from ms-paint. When i tried to save the file as jpg file I did not change the option in SaveTypeAs combo from Monochrome bit map(default option for mspaing ) to JPEG file interchange format. I just gave the name 1.jpg while the file type in the combo below was different.
And it didnt work. Hope that may bring some idea in ur mind...what was wrong in the second step.
thank you mausam. i tried what you mean, save 3.jpg as Monochrome bit map(default option), but i failed again. i don't know why it doesn't work with my jpg....