Menuapp - dynamic object creation

  • Thread starter Patrick Goovaerts
  • Start date
P

Patrick Goovaerts

Hi,

I am trying to build a menu with applications. I need to instantiate/set
applicationobjects for each application in the menu (sounds logic). I
wonder if it is possible to do this 'dynamically'. I mean, when i have a
list (from database) of applications, is it possible to create each object
without adding code over and over for each new app? This would allow me to
add a new application to a database without changing the code in the
menuapp.

Example:
Now i have:

// application 1
if
((jTree.getLastSelectedPathComponent().toString()).equals("FrameTestje")){
if (myFrameTestje==null){
myFrameTestje = new testInternalFrame();
createPanel(myFrameTestje);
}
activatePanel(myFrameTestje);
}

// application 2
if
((jTree.getLastSelectedPathComponent().toString()).equals("PanelTestje")){
if (myPanelTestje==null){
myPanelTestje = new testApp();
createPanel(myPanelTestje);
}
activatePanel(myPanelTestje);
}

... // application x


I want something like this:
if
((jTree.getLastSelectedPathComponent().toString()).equals("anAppName")){
if (anAppName==null){
anAppName = new anAppName();
createPanel(anAppName);
}
activatePanel(anAppName);
}

thanks
 
J

John B. Matthews

"Patrick Goovaerts said:
Hi,

I am trying to build a menu with applications. I need to
instantiate/set applicationobjects for each application in the menu
(sounds logic). I wonder if it is possible to do this 'dynamically'.
I mean, when i have a list (from database) of applications, is it
possible to create each object without adding code over and over for
each new app? This would allow me to add a new application to a
database without changing the code in the menuapp.
[...]

I don't know of a purely data-driven application framework, but the demo
application SwingSet2 does something like this:

<http://java.sun.com/developer/technicalArticles/javase/6_desktop_features/>
 
S

Stefan Ram

Patrick Goovaerts said:
wonder if it is possible to do this 'dynamically'.

A JMenu already is created dynamically, that is, at run time.
It can use any information available at run time.
Objects, also, are created only dynamically.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,236
Members
46,821
Latest member
AleidaSchi

Latest Threads

Top