Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / June 2005

Tip: Looking for answers? Try searching our database.

change picture in Canvas

Thread view: 
Dimitris \(GIS\) - 20 Jun 2005 14:24 GMT
I have a frame with
a awt.List and a awt.Canvas
I want by selecting diferent elements from the list to change my canvas
picture.
How can I do it?

I try this but it gives me NullPointerException:
if(simList.getSelectedIndex()==0){
       ImageCanvas ic=new ImageCanvas("image.jpg");
             simPicture.update(ic);
     }
Andrew Thompson - 20 Jun 2005 14:53 GMT
On Mon, 20 Jun 2005 13:24:01 GMT, Dimitris (GIS) wrote:

> I have a frame with a awt.List and a awt.Canvas

I have rarely found uses for the Canvas class.
Even image rendering is generally simpler to do on a Component.

> I want by selecting diferent elements from the list to change my canvas
> picture.
> How can I do it?

- Use a number of Canvas's in a CardLayout, and flip
between them.  

- Alternately, you might try refreshing the current Canvas
by either it's own methods (I am not that familiar with
them - check the API docs) or by instantiating a fresh
Canvas and refreshing the GUI.

> I try this but it gives me NullPointerException:
> if(simList.getSelectedIndex()==0){
>         ImageCanvas ic=new ImageCanvas("image.jpg");
>               simPicture.update(ic);
>       }

It sounds as though you are trying the second method
mentioned above, but (shrug) I cannot do much with
code snippets[1] and vague descriptions of errors[2].

[1] <http://www.physci.org/codes/sscce.jsp>
[2] <http://www.physci.org/codes/javafaq.jsp#exact>

Signature

Andrew Thompson
http://www.PhySci.org/codes/  Web & IT Help
http://www.PhySci.org/  Open-source software suite
http://www.1point1C.org/  Science & Technology
http://www.LensEscapes.com/  Images that escape the mundane

Dimitris \(GIS\) - 21 Jun 2005 20:55 GMT
Thank you Andrew

> On Mon, 20 Jun 2005 13:24:01 GMT, Dimitris (GIS) wrote:
>
[quoted text clipped - 27 lines]
> [1] <http://www.physci.org/codes/sscce.jsp>
> [2] <http://www.physci.org/codes/javafaq.jsp#exact>
Andrew Thompson - 22 Jun 2005 05:42 GMT
On Tue, 21 Jun 2005 19:55:43 GMT, Dimitris (GIS) wrote:

> Thank you Andrew

You're welcome..  By the way - did you solve the problem?

Signature

Andrew Thompson
http://www.PhySci.org/codes/  Web & IT Help
http://www.PhySci.org/  Open-source software suite
http://www.1point1C.org/  Science & Technology
http://www.LensEscapes.com/  Images that escape the mundane



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.