I have created a GUI which consists of a JFrame and a menubar. The menu bar has several menus which corresponds to different views (JPanels). Each view displays a number of JTextfield and table. The data in each view can be expressed in either metric
unit or english unit. When user selects a menuitem "JRadioButtonMenuItem" (e.g. SI Unit) contained in a unit selection menu, the data in each view should be changed accordingly to reflect the new unit. However, if the display is already in SI Unit and the SI Unit menu item is clicked, then the view remains the same.
I planned to implement this unit change feature by adding an item listener on the JRadioButtonMenuItem. When user changes the unit selection, the listener method (itemStateChanged) will update and repaint ALL views within this GUI to reflect the new unit.
The problem with this approach is that it is too costly. Remember at each instance, the GUI only shows one view, so it seems to me that I should only update and repaint the view on display. For other views, the update and repaint should be done when user switches view. Am I right? If yes, how can I update the data on a hidden view once user switches view? If no, what would be a better approach? I have a hunch that this has something to do with spontaneous repainting. But my knowledge on this aspect is quite limited.
Please help!
Sam