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 / First Aid / March 2004

Tip: Looking for answers? Try searching our database.

Help with resetting a class. *Beginner

Thread view: 
s9@r\)\( - 10 Mar 2004 14:20 GMT
Hi,

The following 3 private methods are used to set the color, radius, and
location of an object - straightforward enough! How can I use a 4th method
to reset the first three after an initial instance has been created?

 private void setColor();
 private void setRadius();
 private void setLoc();

 public void resetDidge();

TIA

SparX
Christophe Vanfleteren - 10 Mar 2004 14:26 GMT
s9@r)( wrote:

> Hi,
>
[quoted text clipped - 11 lines]
>
> SparX

Keep the old values of those properties around:

public class XXX {
       private Color oldColor;
       private Color currentColor;

       public void setColor(Color c) {
               if(c == currentColor) {
                       return;//nothing changed
               }
               oldColor = currentColor;
               currentColor = c;
       }

       public void reset() {
               setColor(oldColor);
               ...
       }
}

Signature

Kind regards,
Christophe Vanfleteren

s9@r\)\( - 10 Mar 2004 15:09 GMT
> s9@r)( wrote:
>
[quoted text clipped - 37 lines]
> Kind regards,
> Christophe Vanfleteren

Thanks for that, but I'm still a little stuck:

The setColor method sets the Didge color to a color in the array:

private final Color[] colors =
   {Color.blue, Color.black, Color.cyan, Color.green,
   Color.gray, Color.magenta, Color.orange, Color.pink,
   Color.red, Color.white, Color.yellow};

Taking that into account how can I make the public method invoke the other
three to reset the location, radius and color methods.

Sorry if this sounds dumb - I am somewhat!

TIA
s1h1 - 10 Mar 2004 15:25 GMT


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.