Using JPanel

Hi

Can anyone give me an example how to use a JPanel?

What are the advantages (or disadvantages) of using beans instead of servoy components (e.g. JButton vs. Servoy Button)?

Thank you very much. Regards
Birgit

JPanel itself is useless inside Servoy. JPanel is only used as a container for other components in Java.

If you use Servoy components, you get all the good Servoy delivers easily accesible. If you use beans, you have to make it wok for yourself.

Paul

Thank you very much!

This means I cannot add a servoy form to a JPanel? Until now I always used tab panels. But I feel they don’t really fit my needs. I was looking for a container where I could just add forms.

Best regards
Birgit

Set the tabOrientation of a tabPanel to “hidden”: This effectivly given you a JPanel appearance

Paul

Hi Paul

pbakker:
Set the tabOrientation of a tabPanel to “hidden”: This effectivly given you a JPanel appearance

Paul

One should differentiate. A tabless tabPanel only gives a special case of a JPanel, the 1 case. As the name implies, a tab panel is primary a tab panel, and a tabless tabPanel is the 1 case of it. A JPanel is a container to allow more than 1 elements, that’s just what the tabless tab panel can’t do, but what would be useful to have within Servoy.

Best regard, Robert

A tabless panel will show a form. The form is the container (JPanel if you will) for all the elements/components you want to place on it, thus the tabless panel can contain many other elements. If you want multiple forms together: Place multiple tab(less)Panels together on another form.

IMHO the only reason there is for using a JPanel is dynamically building a GUI at runtime. Just using the beans like JPanel, JButton, JTextArea etc won’t be of much use, unless you have built your own plugin to Servoy can communicate with them and vise versa.

In the case of dynamically building GUIs’ at runtime in a way that it’s usefull, I think you would be better of creating a bean with all requirend methods so you can build the GUI and have it interact with Servoy.

Hi,

Looking at the remark of Birgit

was looking for a container where I could just add forms.

and this one made by Robert

A JPanel is a container to allow more than 1 elements

I get the feeling we are talking about two different needs/interpretations.

Concerning the original question and postings made by Birgit I would say the solution Paul mentioned is the correct one. You can add more forms to a tabless tabpanel and call them per index via scripting based on whatever criteria.

A JPanel is some sort of ‘container’ that you can add objects to (in fact you can see it as a Servoy form). To use the JPanel you could add it to the form but you would not have the ‘out-of-the-box-goodies’ that Servoy added to their elements so you would have to create a bean(s) using the JPanel (like paul mentioned) and all other objects to have them ‘communicating’ with Servoy.

The wish to add objects to a JPanel is, imho, the same as adding elements to a form…

So, that brings me to a question I have. What is it that you want to do here? And maybe why?

What I wanted to do is:

I defined 3 forms. I want to place them on the left side of my main form. On top of each other. These 3 forms are used as the selection part. On the left I would display details.

Between selection and detail I’d like to position a Splitter (JSplitPane). Since the splitter needs only a left component and a right component (or top and down), I have to define an additional form to compose the 3 selection forms into one (a form with 3 tabless tab panels). With a “container form” (like JPanel) it would have been easier: I just add this container to my main form, add the 3 selection forms to the container and tell the splitter, that the left component is the container form.

The reason, why I defined 3 forms instead of 1 is: I reuse these forms in other contexts.

Since I place an other, horizontal splitter, to my main form, the problem is doubled.

I hope this explains why I was looking for a container form. And it should explain why a tab panel does not solve this. Of course you can add more than one form to a tab panel. But not to the same tab.

Regards
Birgit

It might be me but I don’t really see the difference in what you write here

Between selection and detail I’d like to position a Splitter (JSplitPane). Since the splitter needs only a left component and a right component (or top and down), I have to define an additional form to compose the 3 selection forms into one (a form with 3 tabless tab panels). With a “container form” (like JPanel) it would have been easier: I just add this container to my main form, add the 3 selection forms to the container and tell the splitter, that the left component is the container form.

when you think of Java OR Servoy. But I think I get your picture when I think of the fact that you DON’T want to use an extra form but instead pick up the JPanel (combining the best of both worlds) as a bean and position that on the form instead of creating a new form. Is that what your are trying to tell (or better I am trying to understand). In that case I see what you mean and I even think I can agree. Took a long time but the result is there…

To explain a problem without (really) talking on the phone or showing the code example is quite difficult. And it’s even more difficult if you never had the same problem.

So, I’m happy you could follow my thoughts :)

Regards
Birgit