Elegant way to add a new form instance to a Swing object

Discuss all feature requests you have for a new Servoy versions here. Make sure to be clear about what you want, provide an example and indicate how important the feature is for you

Elegant way to add a new form instance to a Swing object

Postby sanderp » Fri Dec 07, 2007 6:21 pm

Hi,

As far as i know (please correct me if i'm wrong) the only way to display a Servoy form in a Swing or awt object (for example, the JSplitpane and JInternalFrame beans) is to add the form to a tabpanel and then add that tabpanel to the bean. Because there is no way to create a new "tabpanel instance", it is impossible to add a newly created form instance to a Swing or awt container.

I have written my own "MDI Desktop" plugin that uses a JDesktopPane and JInternalFrame's. It works, but at the moment i unfortunately have to use an extremely ugly method to get a new form instance in a new MDI Window: I let Servoy create a non-modal window containing the form and i then 'steal' the parent component out of it by literally doing a few getParent() calls on a random form element. (this is impossible from javascript but it works from a java plugin)

I think it would be great if there would be a more elegant way to do this.

Possible solutions:

- let the form object itself behave like a java.awt.Component

- create a form controller method that returns the Component
sanderp
 
Posts: 15
Joined: Thu Aug 16, 2007 2:06 am

Postby IT2Be » Fri Dec 07, 2007 6:42 pm

That is a faulty assumption.

You will have to do some searching but you can add a form just as you would when you work with a true Java app.

Either on the forum or in Servoy Magazine you should be able to find how to do it...
Marcel J.G. Trapman (IT2BE)
SAN partner - Freelance Java and Servoy
Servoy Components - IT2BE Plug-ins and Beans for Servoy
ServoyForge - Open Source Components for Servoy
User avatar
IT2Be
Servoy Expert
 
Posts: 4766
Joined: Tue Oct 14, 2003 7:09 pm
Location: Germany

Postby sanderp » Fri Dec 07, 2007 6:59 pm

I have already done a lot of searching :)

The only thing i could find about this, is this forum topic:

http://forum.servoy.com/viewtopic.php?p ... e0e7bfb752

.. in which pbakker suggests to use a tabpanel.

The treecontrol sample solution also uses tabpanels.

But maybe i'm not using the right search terms? Can you point me in the right direction?
sanderp
 
Posts: 15
Joined: Thu Aug 16, 2007 2:06 am

Postby IT2Be » Fri Dec 07, 2007 7:06 pm

hmmm, sorry :oops:

You indeed need to use a tabPanel
Marcel J.G. Trapman (IT2BE)
SAN partner - Freelance Java and Servoy
Servoy Components - IT2BE Plug-ins and Beans for Servoy
ServoyForge - Open Source Components for Servoy
User avatar
IT2Be
Servoy Expert
 
Posts: 4766
Joined: Tue Oct 14, 2003 7:09 pm
Location: Germany

Postby Harry Catharell » Fri Dec 07, 2007 7:18 pm

Hi,

It seems that you could be there with that linked thread.

I may be mistaken but if you have added your tabpanel to the bean then the tabpanel has an element name - say 'tabs_70'

You can use the element tab functions to manipulate the tabs/forms attached to it.

Thus you have fx calls like: addTab(), removeTabAt() etc which would allow you to erase and place forms at will using Servoy native methods

So check out those functions in the method editor and / or docs

Hope this helps

Cheers
Harry
Harry Catharell
 
Posts: 812
Joined: Fri Sep 26, 2003 10:23 am
Location: Milton Keynes, England

Postby sanderp » Sat Dec 08, 2007 9:14 pm

Indeed, that allows you to add form instances to an existing tabpanel that's already in a bean.

It still doesn't allow you to create a new form instance and to add that form instance to a new swing object, for example a freshly created JInternalFrame.

The problem is that you need a separate tabpanel for each form instance/JInternalFrame pair and there's no way to create one programmatically.
sanderp
 
Posts: 15
Joined: Thu Aug 16, 2007 2:06 am


Return to Discuss Feature Requests

Who is online

Users browsing this forum: No registered users and 3 guests