Results 1 to 3 of 3

Thread: refesh for SWING?

  1. #1

    Thread Starter
    Hyperactive Member CaptainPinko's Avatar
    Join Date
    Jan 2001
    Location
    London, Ontario, Canada
    Posts
    332

    refesh for SWING?

    when i remove components from a SWING container i still see them, is there a refresh or repaint or update method i should call? i've checked the api but all the methods i found reuiqre a graphics paramether and for the life of my i wouulddn't know what to pass to it
    "There are only two things that are infinite. The universe and human stupidity... and the universe I'm not sure about." - Einstein

    If you are programming in Java use www.NetBeans.org

  2. #2
    Dazed Member
    Join Date
    Oct 1999
    Location
    Ridgefield Park, NJ
    Posts
    3,418
    Which method are you using? Just Curious
    public void remove(int index);
    public void remove(Component comp)
    public void removeAll();

    Two things you want to take into consideration with working in swing. 1.) You may need to call invalidate() if you make changes to the appearance of a displayed component. 2.) You must call validate() on Containers that have been invalidated(typically by the addition or invalidation of a child).

    The invalidate() method is typically called on a Container to indicate that it's children need to be laid out, or on a Component to indicate that it needs to be re-rendered. Usually this method is called automatically but ive seen situations where this fails to take place (for instance when changing the size of a JButton by changing it's label or font.) In this case you must call invalidate() on the Component to mark it as invalid and validate() must be called on the Container().

  3. #3

    Thread Starter
    Hyperactive Member CaptainPinko's Avatar
    Join Date
    Jan 2001
    Location
    London, Ontario, Canada
    Posts
    332
    i tried both remove (Component) and i tried removeAll()

    as a thought you MUST be able to clone user(?) defined classes because all classes are fundamentally user-defined unless specifically in the JVM like arrays or something.
    "There are only two things that are infinite. The universe and human stupidity... and the universe I'm not sure about." - Einstein

    If you are programming in Java use www.NetBeans.org

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width