Archived

This topic is now archived and is closed to further replies.

CPops57

[java] Displaying images and drawing in a gui application?

Recommended Posts

I have an application I have written, but I can''t seem to get some logos and stuff I have to display within the gui. Ideally I''d like to put the picture in its own little panel. Any advice on how to do this display within an application would be appreciated. Thanks.

Share this post


Link to post
Share on other sites
Hi CPops57,

try a JLabel with an image:


  
JFrame mainFrame = new JFrame("JLabel test");
Container cPane = mainFrame.getContentPane();
cPane.setLayout(new BorderLayout());
cPane.add(new JLabel( new ImageIcon( "../logo1.png" ) ), BorderLayout.CENTER );
mainFrame.setVisible(true);
mainFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);


that should do it.

have fun

Share this post


Link to post
Share on other sites