The Artima Developer Community
Sponsored Link

Java Answers Forum
Help! How to change panel's image?

3 replies on 1 page. Most recent reply: Jun 16, 2002 10:27 PM by Charles Bell

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 3 replies on 1 page
Cloner

Posts: 2
Nickname: cloner
Registered: Jun, 2002

Help! How to change panel's image? Posted: Jun 9, 2002 10:58 PM
Reply to this message Reply
Advertisement
I needed to change image of a JPanel type array, can I use Icon to new an ImageIcon or how can I change the image of the array element?


Matt Gerrans

Posts: 1153
Nickname: matt
Registered: Feb, 2002

Re: Help! How to change panel's image? Posted: Jun 10, 2002 12:35 AM
Reply to this message Reply
Huh?

Cloner

Posts: 2
Nickname: cloner
Registered: Jun, 2002

Re: Help! How to change panel's image? Posted: Jun 10, 2002 2:38 AM
Reply to this message Reply
That is, if I want to change an image in square[j] that is type JPanel,how?

Charles Bell

Posts: 519
Nickname: charles
Registered: Feb, 2002

Re: Help! How to change panel's image? Posted: Jun 16, 2002 10:27 PM
Reply to this message Reply

JPanel square[j] = new JPanel();
JLabel imageLabel[j] = new JLabel(new ImageIcon("myimage.gif"));
square[j].add(imageLabel[j]);


and later in the program when you want to change the image:

imageLabel[j].setIcon(new ImageIcon("newimage.gif"));

Flat View: This topic has 3 replies on 1 page
Topic: Dynamic Binding Previous Topic   Next Topic Topic: Help with Excelsior Jet 2.5

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use