In my Java app i'm having a complex GUI which has certain JPanel (custom control) repeated, lets say, 100 times (in reality it could be more, but i don't wanna make this example too complex). Each of those 100 JPanels contains 4 JTextBox controls that show certain values to the users.
JTextBoxes of one panel may be empty, while in another only one may have a value, in some other all boxes may show some numbers and you get the idea - i don't know upfront which textbox of which panel will contain which data.
Now, in order to reduce memory footprint i started learning about the Flyweight design pattern. It seems like exactly the thing i need but, if i keep one JPanel as a seed, and use it to represent other 99 panels (just changing the JTextBox values accordingly) it means all those panels will share the common reference.
In that case, changing JTextBox values in one of them would also change value in all others, right? How to overcome this problem and still keep the memory footprint of the application low?
Am i missing something?
Aucun commentaire:
Enregistrer un commentaire