#gif doesnt display

1 messages · Page 1 of 1 (latest)

silk edgeBOT
#

<@&987246487241105418> please have a look, thanks.

silk edgeBOT
#

While you are waiting for getting help, here are some tips to improve your experience:

Code is much easier to read if posted with syntax highlighting and proper formatting.

If nobody is calling back, that usually means that your question was not well asked and hence nobody feels confident enough answering. Try to use your time to elaborate, provide details, context, more code, examples and maybe some screenshots. With enough info, someone knows the answer for sure.

Don't forget to close your thread using the command </help-thread close:1027500463647621170> when your question has been answered, thanks.

worldly cargo
#

have u tested whether gifs work at all in jlabel?

#

try that first

#

can u show the code that works please

#

yes. share that please

#

can u try out an url to some basic image?

#

lets say this url https://www.pngall.com/wp-content/uploads/2016/06/Rock-PNG-HD.png

#

does this work or is it white as well?

#

if its white as well, JLabel just doesnt support "internet"

silk edgeBOT
#

Detected code, here are some useful tools:

Formatted code
public class Main {
  public static void main(String[] args) {
    SwingUtilities.invokeLater(() -> {
      JFrame frame = new JFrame("U GOT ROCK'ED LMAOOOOOOOO");
      ImageIcon gifIcon = new ImageIcon("/Users/username/Desktop/ZusheeGame/src/main/java/com/zushee/rock.gif");
      JLabel gifLabel = new JLabel(gifIcon);
      JPanel panel = new JPanel();
      panel.add(gifLabel);
      frame.getContentPane().add(panel);
      frame.setPreferredSize(new Dimension(400, 300));
      frame.pack();
      frame.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
      frame.setLocationRelativeTo(null );
      frame.setVisible(true);
      ((ImageIcon) gifLabel.getIcon()).getImageObserver();
      gifIcon.setImageObserver(gifLabel);
      gifIcon.getImage().flush();
    }
    );
  }
}
worldly cargo
#

well, there u go

#

it just doesnt support any urls

#

us ethe constructor that takes Icon instead of String

#

which u can feed with a ImageIcon

#

which can be created out of an url