Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Applet reloads with old information

Posted on 2006-10-22
9
Medium Priority
?
207 Views
Last Modified: 2010-03-31
Hello experts,

I have a Java applet that allows users to draw onto a background. When the Applet is reloaded to use a different background, all the user's previous drawings remain and overlay the new background.

How do I get my Applet to refresh the graphics when it initializes?

Thanks,
Matt.
0
Comment
Question by:mb2297
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
  • 2
  • +1
9 Comments
 
LVL 14

Expert Comment

by:hoomanv
ID: 17784001
Clear the drawings
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 17784003
Actually that's simple. The difficult thing is to make them stick ;-). Just make sure that no drawing takes place in the paint method at that time
0
 

Author Comment

by:mb2297
ID: 17784102
Sorry, I don't quite follow you.

Is there a method I can call that clears all graphics?
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 14

Accepted Solution

by:
hoomanv earned 750 total points
ID: 17784166
Depends on how you store them
If they are just painted on the Canvas or an ImageBuffer
Then clear them by filling it by background color
But if they are stored as individual elements like lines and circles
So you might want to remove them to not being painted anymore
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 17784175
If custom drawing is occurring, you need to flag it 'on or off'
0
 
LVL 92

Assisted Solution

by:objects
objects earned 750 total points
ID: 17785640
As hoomanv has siad you need to clear all your stored drawing.
you can do this in the start() method of your applet.
0
 

Author Comment

by:mb2297
ID: 17803961
This might be more complicated than I first thought.

What I really want to do is completely reset the Applet. No information should transfer when the Applet reloads - it should be as if I was running it for the first time. At the moment, I have some Singletons which all behave as they were before the reload.

Is there a simple way to reset everything, or do I have to build that functionality into all my classes?

Thanks,
Matt.
0
 

Author Comment

by:mb2297
ID: 17804404
I have the additional problem that the panel which holds the background image gets autosized according to the image loaded into it. Once the background image is changed, the image panel does not re-adjust it's size.

Isn't there some kind of reinitialize function built in to Swing components?

Thanks,
Matt.
0
 

Author Comment

by:mb2297
ID: 17859739
All the problems I was having here are explained in the accepted answer to this question: http://www.experts-exchange.com/Programming/Programming_Languages/Java/Q_22039366.html

In the end I used the destroy() method of the Applet to manually clear my drawings, and the start() method to resize the image panel.
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
Suggested Courses

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question