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

Playing Sound and displaying images!!!!!!!!

 
Jyothsna Sri Y
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello everyone,
I have a doubt regarding the way to display images and play sound files using java.
I'm importing:
import javax.media.*;
the code is:
private Player p;
p = Manager.createPlayer(f.toURL());
p.addControllerListener(new EventHandler());
p.start();
Will this work in linux. Are methods and classes for playing them same on all platforms??
Another question is: can someone tell me how to display a image from a file using java (in linux)?
Thanks,
Jyothsna.
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, methods for playing sounds and displaying images should work no matter what platform you are on.

The easiest way to display an image is to create an ImageIcon and add it to a JLabel. The constructor of the ImageIcon can take an absolute or relative filename and will load the image from that file.



Java supports GIF, JPEG, and PNG (since 1.4 ) "out of the box". For other image formats you may have to use JAI (Java Advanced Imaging API) or third-party code.
 
Jyothsna Sri Y
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Thanks a lot Mr.Pruett. It has worked...
cheers
Jyothsna.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic