Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Adding Gif to Gui

 
Heather Marie
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi!

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!

Heather
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks!!!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic