• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
  • Tim Cooke
  • Knute Snortum
  • Bear Bibeault
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Ganesh Patekar
  • Frits Walraven
  • Carey Brown
  • Tim Holloway

Applet got refreshed

Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Guys,
I had made onr Applet on which u can draw geometric figures like line, circle etc., . My problem is that whenever I perform some window actions my applet get refreshed and all the things that I had drawn on it got lost . My applet again become blank.
I want to know that how I can store these figures in Vector or some other Collection framework so that in case of any window application I retrive them. If any other methos u feel is quite good enough to retrive them , please suggest to me.
Ranch Hand
Posts: 1535
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here's a technique of drawing a shape while dragging and adding it to an ArrayList from which it can be retrieved for drawing.

All the shape creation and manipulation is in the event code. The paint code simply draws it.

If you were to create a data store (fancy term for a separate class to store some data) class to add state to your shapes, eg, color, isSelected, selection color, fill color, stroke, you could add a new instance of it to the ArrayList and retrieve the instance variables from it during painting.

Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!