- I run timeGenrator's main, creates TimeGenerator and ClockPanel.
- timeGenerator calls method addObserver(ClockPanel)
- The ClockPanel creates ClockPanel, then calls method ClockFrame.addPanel(this). To add this JPanel to the JFrame.
I must follow the situation above because:
- TimeGenerator can only add an instance if it created it. I don't know how to call method addObserver() if it did not create that ClockPanel instance.
- Because the panel is created, I let ClockPanel create an instance of ClockFrame and call method ClockPanel.addPanel(this).
- I am trying to create 1 class for each clock view: Clockanalog and a class ClockDigital. but How can I do that? The problem is that only one ClockPanel (analog or digital) can create the ClockFrame.
Without creating the instance in a specific ClockPanel, I don't know how to add it to the ClockPanel.
Hope it's clear... I can provide my code if needed. What Java principle do I lack to successfully refactor this code? If you have suggestions, please do tell. =)