Results 1 to 3 of 3
  1. #1
    Roobiks is offline Member
    Join Date
    Mar 2016
    Rep Power

    Question How to refresh frame in different class


    I have a GUI window with a button.
    When hitting the button it does some commands and afterwards closes the window itself.
    Before closing I want to refresh a frame in a different class.
    How can I access that frame?


  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Eastern Florida
    Rep Power

    Default Re: How to refresh frame in different class

    To call a class's methods, the code needs a copy of the reference to that class's instance.
    If you don't understand my response, don't ignore it, ask a question.

  3. #3
    SurfMan's Avatar
    SurfMan is offline Godlike
    Join Date
    Nov 2012
    The Netherlands
    Rep Power

    Default Re: How to refresh frame in different class

    Maybe this is a bit too much for your requirements, but I want to share my 2 anyway. Maybe you can think about it when your application is growing too big to keep references from everything to everything.

    For our application, I have developed an EventBus. In its simplest form, it's a subcriber/publisher pattern. In a nutshell, a component registers itself as a subscriber on the eventbus to be notified on certain events. The eventbus also has a publish method that publishes those events to all the registered listeners. This way, you don't need references all over the place, but you only need to publish the right event and all the registered components can react on that.
    "It's not fixed until you stop calling the problem weird and you understand what was wrong." - gimbal2 2013

Similar Threads

  1. a new class for a frame
    By curious_programmer in forum New To Java
    Replies: 2
    Last Post: 05-08-2012, 09:33 AM
  2. Draw multiple class objects in one frame
    By jj007 in forum AWT / Swing
    Replies: 2
    Last Post: 01-14-2012, 06:32 PM
  3. Replies: 11
    Last Post: 12-20-2011, 08:40 PM
  4. how to refresh frame during thread
    By cob in forum Threads and Synchronization
    Replies: 4
    Last Post: 08-08-2011, 03:09 PM
  5. Close a frame from another class
    By aborgeld in forum New To Java
    Replies: 11
    Last Post: 03-27-2011, 08:22 PM

Posting Permissions

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