DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

+ Reply to Thread
Results 1 to 4 of 4
  1. #1
    Join Date
    May 2005
    Posts
    22

    reapinting without losing old paints

    I am trying to create a new component at a different location to the old one on the same frame.
    The problem is that when I call the repaint method in the method that creates the new component, I lose the old one. it disappears.

    Is there any way to keep both of these components. I only want to create the new component when a button is clicked, so I need to somehow put everything in a new method.
    I also want to be able to do this a number of times (with an increasing value so that is paints further down each time the button is clicked)

    Thanks

  2. #2
    Join Date
    Jun 2004
    Posts
    199
    Code?

    Are these custom components?

  3. #3
    Join Date
    Jul 2005
    Posts
    22
    I think this solution will work... Every class that extends Object (which I believe every class does by default), you will take all the methods of Object. One of these methods is this:
    protected Object clone();
    This will give you an exact copy (clone) of that object without deleting the orrigional one.

    Hope this helps.

  4. #4
    Join Date
    Nov 2004
    Location
    Norway
    Posts
    1,560
    If that happends you are either recreating the new component using the previous
    components variable name, or your paint job is set up to paint only one instance of
    the component. If you keep on creating new components you should store them
    in an ArrayList that is looped and drawn in the paint job.
    However, this puzzles me:
    The problem is that when I call the repaint method in the method that creates the new component...
    I don't understand it
    eschew obfuscation

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


Top DevX Stories

Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL


Sponsored Links