Help coderanch get a
new server
by contributing to the fundraiser
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Carey Brown
  • Mikalai Zaikin
Bartenders:
  • Lou Hamers
  • Piet Souris
  • Frits Walraven

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

 
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Bartender
Posts: 4121
IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
Thanks a lot Mr.Pruett. It has worked...
cheers
Jyothsna.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic