: Could any body like to tell me please how to dispaly a picture or
: any image of any formate into your java window to JForm.
: I would be thankful any any body explain me with a piece of code ,
: how to display an image.
: Please tell me all the method avalible or tell me some use full
: links for that.
: Thanks
:
:
The easiest for this is to use the Image class. Class Description:
http://java.sun.com/javase/6/docs/api/java/awt/Image.html
You can design your own JComponent to display or you can package the image into an ImageIcon and show it using a JLabel. ImageIcon/JLabel can also be used directly since ImageIcon can load certain image files directly.
This all applies to the commonly use image formats (jpg/gif/bmp/png).
If you want other image formats, then you to subclass the ImageReader class and implement the necessary methods to read that format.
Here's a simple sample code:
public static void main(String[] args) {
ImageIcon icon = new ImageIcon("helloworld.gif");
// Make new icon and load it from disk
JLabel label = new JLebel(icon);
// Make new label with the icon
JFrame window = new JFrame();
// make new frame and layout it.
window.setLayout(new BorderLayout());
window.add(label, BorderLayout.CENTER);
window.setsize(640, 480);
window.setDefaultCloseOperation(EXIT_ON_CLOSE);
window.setVisible(true);
}
Useful links:
http://www.google.nl/search?q=images+java
http://java.sun.com/javase/6/docs/api/