#gif doesnt display
1 messages · Page 1 of 1 (latest)
While you are waiting for getting help, here are some tips to improve your experience:
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.
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"
Detected code, here are some useful tools:
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();
}
);
}
}