This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
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
Have you checked out Aspose?
subject: Adding Gif to Gui
It's not a secret anymore!