Skip to main content

Displaying an Image file inside the BorderLayout GUI

1 reply [Last post]
lucas27
Offline
Joined: 2008-10-03
Points: 0

I have a quick question regarding the use of image files (.png) in Java's GUI.

I'm working on a public class that extends JPanel, which uses the BorderLayout to display a window. I know how to add sliders, buttons, etc to my BorderLayout window, but what I'm trying to do is display an image.

How can I do this?

Thanks for reading this.

edit:
Or is there any other way to display some sort of image in BorderLayout?

Message was edited by: lucas27

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
linuxhippy
Offline
Joined: 2004-01-07
Points: 0

Hi,

JLabel is able to host images, so this is probably the shortest way, without creating a image-display widget:
ImageIcon icon = createImageIcon("images/middle.gif");
label3 = new JLabel(icon);

Found here: http://java.sun.com/docs/books/tutorial/uiswing/components/label.html

lg Clemens