• Post Reply Bookmark Topic Watch Topic
  • New Topic

Showing a GIF file in a layout  RSS feed

 
Matt Bradley
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi i am currently trying to display a GIF file on a gridLayout. Which is the best way to do this, the drawImage() function? any help would be greatful!
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
add a JLabel to the gridlayout, using the .gif file as the label's icon
 
Pat Hays
Ranch Hand
Posts: 138
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Matt

add a JLabel to the gridlayout, using the .gif or .jpg file as the label's icon

Eg:
-----------------------
jLabel1 = new JLabel();
jLabel1.setIcon(new ImageIcon("C:\\images\\image001.jpg"));

contentPane = (JPanel)this.getContentPane();
contentPane.setLayout(new GridLayout(1, 0, 0, 0));
contentPane.add(jLabel1, 0);
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!