wood burning stoves 2.0*
The moose likes Swing / AWT / SWT and the fly likes Refreshing a J-Frame Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Refreshing a J-Frame" Watch "Refreshing a J-Frame" New topic

Refreshing a J-Frame

Ramzi Hajaj

Joined: Aug 19, 2012
Posts: 13

Atm i have:

1. a class consisting of j-frame that is constructed by feeding in parameters.

2,These parameters change throughout the program.

3.This change occurs after a user response (comes through button click).

4. The GUI layout is always the same.

How do i refresh the object with new parameters without destroying it and creating a new one?

Basically the problem is that i need to refresh from the button click but this GUI class has no information?
Kemal Sokolovic

Joined: Jun 19, 2010
Posts: 825

Why are you adding MouseListeners to JButton controls?
Shouldn't you use ActionListener instead?

The quieter you are, the more you are able to hear.
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
> How do i refresh the object with new parameters without destroying it and creating a new one?

create a refresh() method to update the components.
this may mean moving the scope of some components from the constructor to a class field.

if the new parameters are just changes in text or icons etc, the update will occur immediately,
some other changes may require you to revalidate()/repaint() the parent container 'contentPane'
I agree. Here's the link: http://aspose.com/file-tools
subject: Refreshing a J-Frame
Similar Threads
Switching between two forms
mouseClicked event for the "Cancel button"
Resizing JPanel and its inner components when JFrame is maximised
Won't repaint!
Prevent Duplicate value from jlist to jlist by way of a jbutton