How to implement a JSplitpane bean

Questions and answers on developing, deploying and using plugins and JavaBeans

How to implement a JSplitpane bean

Postby pbakker » Tue Jan 06, 2004 5:55 pm

Hi, I've been struggling to get it working, but in the end it wasn't that difficult.

Basically, the issue is that the elements that you want to have in the two parts of the split pane need to be on the same form as the JSplitpane bean.

Since most likely you want to have a form in each part of the split pane and forms are not elements on other forms, you have to work around this. Luckely, Servoy offers the oppertunity to, sort of, place a form in a form, by using a tabpanel of which you set the TabOrientation to "Hide".

Currently, TabPannels can only show related forms, but I think we'll be seeing unrelated tabpannels shortly.

So, place two TabPannels on your form + the JSplitPane bean. Be sure to name all three elements (else you cannot call them in a method).

Now, create the following method whcih you attach to the form as an OnLoad event:

elements.split.orientation = 0 //0 = horizontal split, 1 = vertical split
elements.split.topComponent = elements.tabs1; //assign 1st tabpanel elements.split.bottomComponent = elements.tabs2; //assign 2nd tabpanel
elements.split.dividerLocation = 145; //set the position of the pane divider

(in my example, the bean is called "split" and the tabpannel are called "tab1" and "tab2")

When you now open the Form in view mode, you will see both froms that were in the TabPanels inside the JSplitpane bean. To get rid of the original TabPanels (yes, they are also still on the main form, but not accessible), just place then under the JSplitpane bean.

Hope this helps you....

Paul
pbakker
 
Posts: 2822
Joined: Wed Oct 01, 2003 8:12 pm
Location: Amsterdam, the Netherlands

Postby Bert » Tue Jan 06, 2004 6:03 pm

Great information, Paul :D
Where can I download this bean?

Thanks again...
Bert de Graaff
ATB Software Servoy Developer manage your business anywhere
User avatar
Bert
 
Posts: 201
Joined: Tue May 20, 2003 11:16 am
Location: Stramproy - NL

Postby pbakker » Tue Jan 06, 2004 6:08 pm

That is the cool thing.... you don't have to!

It ships standard with Servoy. Click the Place Bean button, right next to the Place Portal button in Develloper and select JSplitpane.

One little issue: sometimes beans go missing when develloper is closed. This will be fixed in beta 6, according to Jan, which is scheduled this week, according to Johan.... :D

Paul
pbakker
 
Posts: 2822
Joined: Wed Oct 01, 2003 8:12 pm
Location: Amsterdam, the Netherlands

Postby IT2Be » Sat Jan 10, 2004 1:44 pm

Thanks Paul, this tip learns me to dig deeper like you did. Never thought of just calling the element without any method.

Don't forget to anchor fields and forms. It works like a charm!

Great tip...
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 ROCLASI » Wed Jan 14, 2004 5:42 pm

For some odd reason I can't drag the splitter. Anyone else experiancing this? Also the positioning of the splitter doesn't work. :cry:

I would love to be able to use the splitpane.
Robert Ivens
SAN Developer / Servoy Valued Professional / Servoy Certified Developer

ROCLASI Software Solutions / JBS Group, Partner
Mastodon: @roclasi
--
ServoyForge - Building Open Source Software.
PostgreSQL - The world's most advanced open source database.
User avatar
ROCLASI
Servoy Expert
 
Posts: 5438
Joined: Thu Oct 02, 2003 9:49 am
Location: Netherlands/Belgium

Postby IT2Be » Wed Jan 14, 2004 7:28 pm

Well, it should work, maybe you can try to put the splitpane in the foreground... Positioning is remembered in the properties maybe you can set it to the position you want also!
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 pbakker » Wed Jan 14, 2004 7:46 pm

Positioning of the Splitter thorugh a method has to happen after you assign the top/bottom or left/right components, or else it's directly overwritten. Maybe that happens?

As for not being able to move the splitter: probably a property of the bean that you have to set? I never experienced this.

Paul
pbakker
 
Posts: 2822
Joined: Wed Oct 01, 2003 8:12 pm
Location: Amsterdam, the Netherlands

Postby ROCLASI » Thu Jan 15, 2004 7:08 pm

I use the exact source you gave.

I experimented with other controls in it like buttons (using the same names).
Same result. They all resize to the max size inside the splitpane and the splitter can't be moved. I removed all anchors from the buttons tho...still they resized. Normal behavior ?


I am using Mac OSX 10.3.2 and Servoy 1.2-build 259
Also the beans are *always* missing after quitting and opening servoy.
Known bug I know.
Robert Ivens
SAN Developer / Servoy Valued Professional / Servoy Certified Developer

ROCLASI Software Solutions / JBS Group, Partner
Mastodon: @roclasi
--
ServoyForge - Building Open Source Software.
PostgreSQL - The world's most advanced open source database.
User avatar
ROCLASI
Servoy Expert
 
Posts: 5438
Joined: Thu Oct 02, 2003 9:49 am
Location: Netherlands/Belgium

Postby pbakker » Thu Jan 15, 2004 9:31 pm

Very odd, never seen it. I do know that I work with Servoy 2.0 beta's. Maybe something has been fixed in new versions...

The problem that beans go missing after closing Develloper is at least fixed in 2.0 beta 6.

Paul
pbakker
 
Posts: 2822
Joined: Wed Oct 01, 2003 8:12 pm
Location: Amsterdam, the Netherlands

Postby gatzki » Tue Apr 20, 2004 10:43 am

Hi ,

thanks for sharing the technique ...

now, with the recent release (12), you have to change the method:

Code: Select all
elements.split.setOrientation(1); //vertical
elements.split.setLeftComponent(elements.tabs1);
elements.split.setRightComponent(elements.tabs2);
elements.split.setDividerLocation(0.2); //Location as value betwen 0 and 1
gatzki
 
Posts: 6
Joined: Tue Mar 09, 2004 1:04 pm
Location: munich


Return to Plugins and Beans

Who is online

Users browsing this forum: No registered users and 13 guests

cron