Skip to main content

Displaying an Image file inside the BorderLayout GUI

1 reply [Last post]
Joined: 2008-10-03

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.

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.
Joined: 2004-01-07


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:

lg Clemens