Search code examples
javauser-interfacejframejpanelextend

How to duplicate a Java GUI Jframe?


I have use a Jframe, JPanel made a program which is a countdown Timer. Everything is working good. Now, what I want to do is to duplicate it as 10 replicas. That means I want to 10 countdown Timer in one GUI. Is there any way can do it without write same code 10 times? Please help


Solution

  • You can use some design patterns

    • Java composite pattern : to create a Timer object which will have all your graphics components of the countdown timer, also it should have their configuration to,
    • Java prototype pattern : to clone this timer 10 times

    For more info see this java composite pattern, java prototype pattern