I had developed a Swing GUI which contains 12 JPanels. Initially, all the JPanels code was written in the main JFrame class code. As a result, the code became too long (10,000+ lines).
Now I want to refactor the code to break the code into 13 classes (12 classes each for one JPanel and 1 class for the main JFrame) instead of 1 class carrying all the code.
But I have some confusions which is as follows:
- Initially those 12
JPanels were set on a "Card"JPaneland the layout of the "Card"JPanelwas set toCardLayoutso that only 1JPanelout of those 12JPanels showed at a time based on the button on which use has clicked. Now when I have seperated those 12JPanels from theMainJFormand implemented each of them into its own class, I think I need to instantiate a correspondingJPanelfirst whenever a user clicks on the button. So, would it better to do this heavy task on the EDT (Event Dispath Thread). If no, then Will it work to make a instance of the JPanel inSwingWorkerthread and pass a ref. to EDT?