Buttons get very small in JToolBar

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

Buttons get very small in JToolBar

Postby mjekl » Mon Mar 28, 2005 6:00 pm

Hi,

I can't seem to make the JToolBar bean work.

I have the JToolBar and couple of buttons on a form that runs a method appropriately called "initTool" to initialize the JToolBar. The methods adds the buttons and a separator correctly to the JTooBar, but the buttons get very small and I can't find a way to get them there natural size.
As expected, the buttons do work since I attached some methods to check it.

Here's the code for the initTool form method:
Code: Select all
elements.bean_224.add(elements['btnRecView']);
elements.bean_224.addSeparator();
elements.bean_224.add(elements['btnAddRec']);

elements.bean_224.upDateUI;


Txs for the help.
mjekl
mjekl
 
Posts: 114
Joined: Sat Nov 13, 2004 10:17 pm
Location: Lisbon

Postby mjekl » Tue Mar 29, 2005 3:01 pm

:oops: I need to specify the imageMedia or text property. This way the JToolBar will rescale the button apropriately.

mjekl
mjekl
 
Posts: 114
Joined: Sat Nov 13, 2004 10:17 pm
Location: Lisbon

Postby Harjo » Tue Mar 29, 2005 6:46 pm

Hi Mjekl,

can you give us a nice (complete) example, of how to use the Jtoolbar?
Harjo Kompagnie
ServoyCamp
Servoy Certified Developer
Servoy Valued Professional
SAN Developer
Harjo
 
Posts: 4321
Joined: Fri Apr 25, 2003 11:42 pm
Location: DEN HAM OV, The Netherlands

Postby pbakker » Wed Mar 30, 2005 8:50 am

There ain't much to it:

Just drop a JToolBar bean on your form and add elements that are allready on your form to it:
Code: Select all
elements.bean_224.add(elements['btnRecView']);
elements.bean_224.addSeparator();
elements.bean_224.add(elements['btnAddRec']);

elements.bean_224.upDateUI;


The code above is a good example of that. the "elements['btnRecView']" is one of these elements on the form, named 'btnRecView'.

My experience: It works fine for buttons (all things you set on a button still work). When adding fields to a JToolBar bean, they tend to get stretched. You could solve this by setting min and max size on the element, but this is not something Servoy exposes on elements.

Just my 5 cents...

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

Postby mjekl » Wed Mar 30, 2005 7:25 pm

Hi,

Something I really enjoy with JToolBar is that because we add simple "Servoy Buttons" to it it's possible to call methods from it!

This "something extra" in JToolBar is what is really missing in Servoys ability to use beans - calling methods from a bean!

When I tried to use JToolBar for the first time I tried to add JButtons to it! I wonder what's the use of JButton (in Servoy) if we can't call Servoy methods from it.

I have a stupid ideia about how to call servoy methods from beans, here it goes (I'm going to take flak for opening my big mouth:-)

There could be a mechanism in Servoy that listened to specific elements (beans) to see if they issued some command. This mechanism would be somthing like a Action manager that would bridge registred elements to servoy methods. With registration there could be some optimization of the listening activities of the action manager. So although I do not have a clue about Java in abstract I can't see why this couldn't work.

mjekl
mjekl
 
Posts: 114
Joined: Sat Nov 13, 2004 10:17 pm
Location: Lisbon

Postby pbakker » Thu Mar 31, 2005 9:05 am

Servoy cannot "listen" to commands fired by beans, because there will be nothing fired by a Bean, unless you register a so called "Listener"

As you can see in the functions of a Beans, there are several addXXXXXListeners() functions. They all take a different input param, like an ActionListener, Changelistener etc.

One could write a plugin with functions that returns those Java Listener objects and then you can add those Listener objects to the Bean yourself in scripting.

So, to sum it up: The functions in the plugin would take a global method as parameter and returns a xxxxxListener, which you can add to the bean. Once you have a certain action performed on the bean that will trigger the listener, the global method will be fired.

Just some background. I think that in pretty much all cases, Servoy supports allready the events you need. If they don't there are good reasons for not supporting them.

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

Postby mjekl » Thu Mar 31, 2005 12:48 pm

Txs for the explanation Paul.

One could write a plugin with functions that returns those Java Listener objects and then you can add those Listener objects to the Bean yourself in scripting.


And where and how can we get those Listner Objects?
Inline Java! Write them ourselfs?
Or are there any of them available? And how can we get them in Servoy?
I suppose they follow a pretty well defined categorization, is this so?

Just some background. I think that in pretty much all cases, Servoy supports allready the events you need. If they don't there are good reasons for not supporting them.


Your right. But I suppose beans also introduce the possibility of using some GUI that demand the ability to fire methods like a sliding bar (outlook side menu style).

Mjekl
Last edited by mjekl on Thu Mar 31, 2005 12:58 pm, edited 1 time in total.
mjekl
 
Posts: 114
Joined: Sat Nov 13, 2004 10:17 pm
Location: Lisbon

Postby pbakker » Thu Mar 31, 2005 12:58 pm

And where and how can we get those Listner Objects?
Inline Java! Write them ourselfs?
Or are there any of them available? And how can we get them in Servoy?
I suppose they follow a pretty well defined categorization, is this so?


Don't follow all your questions...

To be able to register Listeners on Beans in methods, you need to have these Listener Objects.

To get them, you need to write a plugin that has functions that returns them. And writing a plugin is done in Java itself (see Servoy website for how to write plugins for Servoy)

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

Postby mjekl » Thu Mar 31, 2005 1:13 pm

Txs Paul for all the info.

Mjekl
mjekl
 
Posts: 114
Joined: Sat Nov 13, 2004 10:17 pm
Location: Lisbon


Return to Plugins and Beans

Who is online

Users browsing this forum: No registered users and 37 guests

cron