File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Swing / AWT / SWT and the fly likes Adding Gif to Gui Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Adding Gif to Gui" Watch "Adding Gif to Gui" New topic

Adding Gif to Gui

Heather Marie

Joined: Sep 25, 2005
Posts: 8

Can anybody give me some simple code from Swing to add a gif file (stored on c drive) to an application for an assignment I'm working on. I thought this would be the easiest part of the whole assignment but for some reason I can't get it. I'm not sure what to use....ImageIcon? Please help! Desperate student!

Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
add the gif file as the icon for a JLabel
add the JLabel to a JPanel
add the panel to the JFrame/contentPane

something like this

Heather Marie

Joined: Sep 25, 2005
Posts: 8
I agree. Here's the link:
subject: Adding Gif to Gui
It's not a secret anymore!