aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes Commands events or function calls between two containers Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Commands events or function calls between two containers" Watch "Commands events or function calls between two containers" New topic
Author

Commands events or function calls between two containers

Charles Van Damme
Greenhorn

Joined: Feb 24, 2009
Posts: 19
Dear experts,

Suppose that we have a container including JButtons and one JTextField, and another one containing JList, JCombobox, JTable ... objects.
Let us also suppose that we want to be able to delete a row in the drop-down list of a JComboBox, in the table ...
I can figure that the best practice is to pass on 'Action events' from one container to the other and to implement listeners. I that correct ?

Which are good tutorials to learn to achieve that the right way ?
A "How to" tutorial of Java ?
The "Java Swing, 2nd Edition Code Examples" of O'Reilly ?
Or must we use between two containers a function call such as 'fireActionEvent()' (for JComboBox) ?

I first used the search engine of this site, but without result.
In the search engines (of the web), which other keywords than those in the subject field of this discussion should I use ?

Some url's of some examples, please.
Thanks for any trial to help me.

P.S.: Brrr... I did not receive an answer to my discussion subject Preventing the drop-down list of a JComboBox to close
Am I asking such special things ?

Have a nice day.
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
> Suppose that we have a container...

assuming your 'containers' are just JPanels etc, all that is needed is for the (e.g.) JComboBox
to have the necessary scope i.e. for the actionListener in the other container to 'see' the comboBox

simple demo

if you comment out the 2 indicated lines, then uncomment the other line, it won't compile because
the actionListen can't 'see' cbo

Charles Van Damme
Greenhorn

Joined: Feb 24, 2009
Posts: 19
Understood. Many thanks, Michael.

And no idea for related subject: Preventing the drop-down list of a JComboBox to close ?
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
> Preventing the drop-down list of a JComboBox to close ?

I'd say it's do-able, probably need to set your own UI overriding whatever method
fires (to close the popup) when the dialog takes focus. But, this is unlikely to work
for all L&F's, so it's gunna be messy.

probably easier to use another component (JList, JTable?), and, if necessary,
control it's display size i.e. show just 1 line, expand to 8 lines when in use, then
return to 1 line size after add/edit/whatever
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Commands events or function calls between two containers