1

I made a GIF using photoshop, here is the result:

enter image description here

It works fine

I am having issues when i load it to my java program. The red lines are bugged (I dont know what it's called), when it goes through the arrow. Here is the screenshot:

enter image description here

Here is the code if it helps in any way

    IDLE_DEFAULT_GIF.setIcon(new ImageIcon("IDLE-GIF.gif"));
    IDLE_DEFAULT_GIF.setBounds(x+128-130,15,204,172); //I set my panel's layout to null
    FSM_PANEL.add(IDLE_DEFAULT_GIF);

MCVE

package vendingmachine;

import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.SwingUtilities;


public class MainFrame extends JFrame{

    //WIDTH & HEIGHT//
    int WIDTH = 300;
    int HEIGHT = 350;

    //PANEL//
    JPanel FSM_PANEL = new JPanel();

    //GIF LABELS
    JLabel IDLE_DEFAULT_GIF = new JLabel();

    public MainFrame(){
        setLayout( null );

        //JFRAME 
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        setSize(WIDTH,HEIGHT);
        setVisible(true);
        setLocationRelativeTo(null);

        INIT_FSM_PANEL();

        repaint();
    }

    public void INIT_FSM_PANEL(){
        FSM_PANEL.setBounds(10, 8, WIDTH, HEIGHT);
        FSM_PANEL.setLayout(null);

        //The gif that caused the issue
        IDLE_DEFAULT_GIF.setIcon(new ImageIcon("IDLE-GIF.gif"));
        IDLE_DEFAULT_GIF.setBounds(10,10,204,172);
        FSM_PANEL.add(IDLE_DEFAULT_GIF);

        add(FSM_PANEL);    
    }

    public static void main(String[] args) {
        SwingUtilities.invokeLater( new Runnable(){

            @Override
            public void run() {
                MainFrame frame = new MainFrame();
            }
        });
    }   
}
user1803551
  • 12,965
  • 5
  • 47
  • 74
Adam
  • 309
  • 1
  • 15
  • Post an [MCVE](http://stackoverflow.com/help/mcve). – user1803551 May 21 '15 at 04:39
  • @user1803551 i provided the MCVE above, thank you for the reply – Adam May 21 '15 at 04:56
  • Are you scaling the image in your code? – jyoonPro May 21 '15 at 05:12
  • @jyoon i did not scale the image, i get the width and height straight from the photoshop's image size. I tried moving the gif a little bit down, the red animaiton on the arrow is there but the pixel block is still there – Adam May 21 '15 at 05:47
  • I *think* that something is wrong with the gif in some way. I put it [here](http://ezgif.com/split) to split it to individual frames. If you select "Ignore optimizations", then the frames where the line moves though the arrow are damaged. Can you have a second look at it? – user1803551 May 21 '15 at 05:50
  • @user1803551 Ok, i tried using the program, and the "idle box" appears to be missing from the frame right? From i can remember, i still have all of the image from all of the frame. What do you think is the problem? (I cannot make sure since i did not bring the PSD file for the gif, im so sorry) – Adam May 21 '15 at 06:05
  • In the damaged frames, everything is missing except for the red line and a bit of the arrow (is it not what you see?). I don't know much about gifs, but the method Swing uses to draw the gif seems to be suffering from that type of damage in the arrow frames. – user1803551 May 21 '15 at 06:10
  • @user1803551 thank you so much, you have helped enough, i know there the problem is now. I will continue to do it myself – Adam May 21 '15 at 06:36
  • This question might be closed because it is not a coding issue (the gif resource is bad). Still, if you check and find that there is more to it than fixing the gif, it can be reopened. – user1803551 May 21 '15 at 08:54
  • Also, [this site](http://en.bloggif.com/gif-extract?id=e97ae70e09278c920db97f80c4bb0d11) shows the same results if you don't mark the checkbox. – user1803551 May 21 '15 at 09:02

0 Answers0