• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Refreshing a J-Frame

 
Ramzi Hajaj
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey

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
Bartender
Posts: 825
5
Java Python Ruby
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why are you adding MouseListeners to JButton controls?
Shouldn't you use ActionListener instead?
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
> 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'
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic