• 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
  • Tim Cooke
  • Devaka Cooray
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Martijn Verburg
  • Frits Walraven
  • Himai Minh

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.
 
It would give a normal human mental abilities to rival mine. To think it is just a tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic