We have a Java Swing application which contains components like JTable, JCombobox, JTextArea and lots of other Swing components.
Now there is a requirement that says we need to create multiple screens/copy of same Java Swing applications. For e.g. if my main Java Swing application is X then I have to create same applications A,B,C,D,... same as X.
So here there are some obvious design constraints that we should not create X applications many times. We should create it only once and utilize them to create other apps A,B,C,D....
There is a problem here these A,B,C... applications may be or may not be subsets of X. It means that A i开发者_运维问答s having less Swing components then X.
There is one way store class files and create app from it but what about Swing components how do we reuse them? Where can we store them?
This is kind of design question. Any ideas..
I think the best you can do is, design your application in a way that you can plug things in and out. So, a plugin/module kind of architecture best suits here. You can design your components module based; if application needs a module/plugin, install that, otherwise don't. Just like we do with our IDEs, like Netbeans, Eclipse, IntelliJ.
As this is a Swing application, I would strongly recommend looking into Netbeans Platform.
All Swing components are Serializable. I think you can create JPanel, show it, serialize it, then restore and show again. I believe that deserilized panel will be shown separately.
Try it with simple panel. If it works try to apply this technique to your application.
精彩评论