3

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 is 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..

Adeel Ansari
  • 39,541
  • 12
  • 93
  • 133
Umesh K
  • 13,436
  • 25
  • 87
  • 129
  • 1
    I am not sure I understand your problem. Swing Components are classes just like anything else. And the default stuff like JTable etc. that you list, are in the JDK libraries by default, so available to all applications. – Daniel Schneller Dec 03 '10 at 09:56
  • No its like all components JTable etc should be created only once and we should use them in other replicas of same applications. For e.g. X application is having JTable so it will get created now A application will use it and B application will not use it. So we need to create something like pool of all Swing components objects and use it to create replicas of main Swing app. – Umesh K Dec 03 '10 at 10:04

2 Answers2

3

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.

Adeel Ansari
  • 39,541
  • 12
  • 93
  • 133
-1

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.

AlexR
  • 114,158
  • 16
  • 130
  • 208
  • 2
    Would not do this - serialization is not guaranteed to work across versions, even minor version changes in the Java Runtime might break this. – Daniel Schneller Dec 03 '10 at 10:01