Refresh Entire UI

Discussion in 'Java' started by Jason Cavett, Aug 4, 2008.

  1. Jason Cavett

    Jason Cavett Guest

    Is there a way to tell a top-level Java Swing component to refresh and
    have all of its subcomponents refresh along with it?

    The reason I am asking is that I have a skinning/theme system in place
    and when the user switches themes, I want it to update on the fly.
    This works with some of the components (icons/text/etc), but I can't
    seem to get the entire GUI to refresh (trying to do this via
    updateUI()).

    Any suggestions?
     
    Jason Cavett, Aug 4, 2008
    #1
    1. Advertising

  2. On 04/08/2008 18:58, Jason Cavett allegedly wrote:
    > Is there a way to tell a top-level Java Swing component to refresh and
    > have all of its subcomponents refresh along with it?
    >
    > The reason I am asking is that I have a skinning/theme system in place
    > and when the user switches themes, I want it to update on the fly.
    > This works with some of the components (icons/text/etc), but I can't
    > seem to get the entire GUI to refresh (trying to do this via
    > updateUI()).
    >
    > Any suggestions?


    Do you mean you changed the UI delegate of each, or at least some,
    Component(s)?

    Have you tried invalidate() + validate() on the root Container (e.g. a
    JFrame)?

    --
    DF.
     
    Daniele Futtorovic, Aug 4, 2008
    #2
    1. Advertising

  3. Jason Cavett wrote:
    > Is there a way to tell a top-level Java Swing component to refresh and
    > have all of its subcomponents refresh along with it?
    >
    > The reason I am asking is that I have a skinning/theme system in place
    > and when the user switches themes, I want it to update on the fly.
    > This works with some of the components (icons/text/etc), but I can't
    > seem to get the entire GUI to refresh (trying to do this via
    > updateUI()).
    >
    > Any suggestions?


    Have you tried any of the validate()/repaint() options?

    --

    Knute Johnson
    email s/nospam/knute2008/

    --
    Posted via NewsDemon.com - Premium Uncensored Newsgroup Service
    ------->>>>>>http://www.NewsDemon.com<<<<<<------
    Unlimited Access, Anonymous Accounts, Uncensored Broadband Access
     
    Knute Johnson, Aug 4, 2008
    #3
  4. Jason Cavett

    Jason Cavett Guest

    On Aug 4, 1:17 pm, Daniele Futtorovic <>
    wrote:
    > On 04/08/2008 18:58, Jason Cavett allegedly wrote:
    >
    > > Is there a way to tell a top-level Java Swing component to refresh and
    > > have all of its subcomponents refresh along with it?

    >
    > > The reason I am asking is that I have a skinning/theme system in place
    > > and when the user switches themes, I want it to update on the fly.
    > > This works with some of the components (icons/text/etc), but I can't
    > > seem to get the entire GUI to refresh (trying to do this via
    > > updateUI()).

    >
    > > Any suggestions?

    >
    > Do you mean you changed the UI delegate of each, or at least some,
    > Component(s)?
    >
    > Have you tried invalidate() + validate() on the root Container (e.g. a
    > JFrame)?
    >
    > --
    > DF.


    I did, and that refreshes some of the components (namely, the menus,
    the JTree contained within the JFrame, etc). However, it does *not*
    refresh the JInternalFrames that I have contained within the parent
    JFrame.

    It's a little bit confusing. Is there something different about the
    JInternalFrames that I'm not understanding?

    Thanks for your response.
     
    Jason Cavett, Aug 4, 2008
    #4
  5. Jason Cavett

    Jason Cavett Guest

    On Aug 4, 1:30 pm, Knute Johnson <>
    wrote:
    > Jason Cavett wrote:
    > > Is there a way to tell a top-level Java Swing component to refresh and
    > > have all of its subcomponents refresh along with it?

    >
    > > The reason I am asking is that I have a skinning/theme system in place
    > > and when the user switches themes, I want it to update on the fly.
    > > This works with some of the components (icons/text/etc), but I can't
    > > seem to get the entire GUI to refresh (trying to do this via
    > > updateUI()).

    >
    > > Any suggestions?

    >
    > Have you tried any of the validate()/repaint() options?
    >
    > --
    >
    > Knute Johnson
    > email s/nospam/knute2008/
    >
    > --
    > Posted via NewsDemon.com - Premium Uncensored Newsgroup Service
    >       ------->>>>>>http://www.NewsDemon.com<<<<<<------
    > Unlimited Access, Anonymous Accounts, Uncensored Broadband Access


    I have. See my response to Daniele.
     
    Jason Cavett, Aug 4, 2008
    #5
  6. On 04/08/2008 19:39, Jason Cavett allegedly wrote:
    > On Aug 4, 1:17 pm, Daniele Futtorovic <>
    > wrote:
    >> On 04/08/2008 18:58, Jason Cavett allegedly wrote:
    >>
    >>> Is there a way to tell a top-level Java Swing component to refresh and
    >>> have all of its subcomponents refresh along with it?
    >>> The reason I am asking is that I have a skinning/theme system in place
    >>> and when the user switches themes, I want it to update on the fly.
    >>> This works with some of the components (icons/text/etc), but I can't
    >>> seem to get the entire GUI to refresh (trying to do this via
    >>> updateUI()).
    >>> Any suggestions?

    >> Do you mean you changed the UI delegate of each, or at least some,
    >> Component(s)?
    >>
    >> Have you tried invalidate() + validate() on the root Container (e.g. a
    >> JFrame)?
    >>

    >
    > I did, and that refreshes some of the components (namely, the menus,
    > the JTree contained within the JFrame, etc). However, it does *not*
    > refresh the JInternalFrames that I have contained within the parent
    > JFrame.
    >
    > It's a little bit confusing. Is there something different about the
    > JInternalFrames that I'm not understanding?


    Sorry, I don't know for sure. Actually, I haven't ever used
    JInternalFrames seriously. Knute might be able to tell you better than I.

    Are you using a JDesktopPane for the JInternalFrames, as advised? Having
    a quick glance at the source code, I don't see anything that might
    intercept the invalidation -- the JInternalFrames are added as children
    to the JDesktopPane, and consequently should be part of the same
    hierarchy. So I don't really know why it doesn't work.

    You might want to manually hide and show the JInternalFrames again, to
    check whether it's merely a refresh problem.

    Then, of course it should be possible to hack around the problem by
    gathering, invalidating and validating the JInternalFrames manually. I'd
    find that unsatisfying if it were my code, so I merely mention it as a
    last resort.

    --
    DF.
     
    Daniele Futtorovic, Aug 5, 2008
    #6
  7. On Aug 5, 2:58 am, Jason Cavett <> wrote:
    > Is there a way to tell a top-level Java Swing component to refresh and
    > have all of its subcomponents refresh along with it?


    The best way to achieve that seems to be along
    the lines of..

    ...
    UIManager.setLookAndFeel( plaf );
    // called from JFrame sub-class, the
    // 'root' component of the GUI
    SwingUtilities.updateComponentTreeUI(this);
    ...

    If that fails for you, I suggest you post an SSCCE
    trimmed to just the JDesktopPane, the JInternalFrames
    and a menu to select the various default PLAFs.

    --
    Andrew Thompson
    http://pscode.org/
     
    Andrew Thompson, Aug 5, 2008
    #7
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Mark
    Replies:
    0
    Views:
    467
  2. brian lanning
    Replies:
    0
    Views:
    604
    brian lanning
    Jul 29, 2003
  3. Per Magnus L?vold
    Replies:
    1
    Views:
    5,137
    John C. Bollinger
    Oct 8, 2004
  4. Pkenty
    Replies:
    0
    Views:
    401
    Pkenty
    May 28, 2004
  5. Jawahar Rajan
    Replies:
    1
    Views:
    294
    Adrienne
    Oct 1, 2003
Loading...

Share This Page