Get the tools you need to learn Java skills fast!
Video tutorials, eBooks, hands-on lab exercises, sample code.
Get started
The moose likes Beginning Java and the fly likes Hoe to display jpg file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Badass: Making Users Awesome this week in the Game Development forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Hoe to display jpg file" Watch "Hoe to display jpg file" New topic

Hoe to display jpg file

Mike Kelly
Ranch Hand

Joined: Jul 18, 2001
Posts: 78
I want to display a picture when a button is clicked on. BinTallOne is the button. Compiler can't resolve symbol, symbol being getImage(). Is there a method I could use to get a jpg file and display it? ActionListener has been implemented and added to button.Thanks Mike
public void actionPerformed(ActionEvent ae) {
String label = ae.getActionCommand();
if (label.equals("BinTallOne")) {
BinTallOne = getImage("MePic.JPG");
Thomas Bigbee
Ranch Hand

Joined: Nov 29, 2001
Posts: 48
The above link will show you how to use image icon
ImageIcon(byte[] imageData)
Creates an ImageIcon from an array of bytes which were read from an image file containing a supported image format, such as GIF or JPEG.
Hope that helps, Tom
Mike Kelly
Ranch Hand

Joined: Jul 18, 2001
Posts: 78
I agree. Here's the link:
subject: Hoe to display jpg file