I had developed a Swing GUI which contains 12 JPanel
s. Initially, all the JPanel
s 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
JPanel
s were set on a "Card"JPanel
and the layout of the "Card"JPanel
was set toCardLayout
so that only 1JPanel
out of those 12JPanel
s showed at a time based on the button on which use has clicked. Now when I have seperated those 12JPanel
s from theMainJForm
and implemented each of them into its own class, I think I need to instantiate a correspondingJPanel
first 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 inSwingWorker
thread and pass a ref. to EDT?