wood burning stoves 2.0*
The moose likes Swing / AWT / SWT and the fly likes How to go about starting to use Java events? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "How to go about starting to use Java events?" Watch "How to go about starting to use Java events?" New topic
Author

How to go about starting to use Java events?

Jacky Luk
Ranch Hand

Joined: Aug 02, 2012
Posts: 590
Don't know if this is for swing.
If I add a hospital in my form, I want to update every combo box in the JTable that has this corresponding field.
How do I start?
Thanks
Jack
m Korbel
Ranch Hand

Joined: Jun 19, 2012
Posts: 154
- JTable tutorial contains describtion about URL Description

- then is stored String value in XxxTableModel, not JComboBox

- String value is stored in the case that JComboBox (DefaultComboBoxModel) contains Item in String, if is there Number or Icon (etc...) then have to change ColumnClass (in XxxTableModel) from String (by default) to real data type stored in XxxComboBoxModel
Jacky Luk
Ranch Hand

Joined: Aug 02, 2012
Posts: 590
Hi,
I cannot get a dropdown menu from the combo using this code snippet.



Thanks
m Korbel
Ranch Hand

Joined: Jun 19, 2012
Posts: 154
- never, do not add / override / modify JComboBox in the Renderer, this action is called lots of times, initalized from every Mouse a Key Events, painted internally (events implemented in API) too,

- is there special reason to see JComboBox as Renderer

- JTable supporting JComboBox, have to change isCellEditable for concrete Column

- potentially coud be therer issue with sorting or filtering for arrays based on Map / HashMap, there isnt implemented any ordering, use util.List instead
Jacky Luk
Ranch Hand

Joined: Aug 02, 2012
Posts: 590
I've got another annoying problem here. Don't know why. But When I clear the model and re-add stuff to it, the JComboBox doesn't reflect it right away
Say originally I had 8 items in the combo box, I add one to it, it still has 8 items in it.




m Korbel
Ranch Hand

Joined: Jun 19, 2012
Posts: 154
- since is possible to add / remove/ modify Item in JComboBox use MutableComboBoxModel instead

- forgot about add /get / modify Items from JComboBoxes Editor, by default this JComponent works for editable JComboBox and/or only in the case that popup is colapsed and (untill) important is that all events are non_finalized for JComboBox untill is popup visible and/or ActionListener, ItemListener ended firing its evens and all events are completed, dot

- then have to play with derived JList and LisSelectionListener and KeyEvent

- sorry you are (see your last 5-8 posts issue with basic knowledges), in the case that you 'll want to some progress == have to post an SSCCE with hardcoded value instead of FileIO or JDBC, otherwise most of suggestion here are helicopter views, equilalent to the asked question, no reason (for most posters here, mee too) to simulating your code snippend by my hands, sorry post an SSCCE

EDIT

have to accepting that (about JComboBox as Editor and Renderer in JTable)

1. JTables view is based on value stored in XxxTableModel

2. cell must be editable for allowing the Editor

3. selected value (finalized value) is stored in XxxTableModel only as String (if XxxComboBoxModel contains String value for Items), there isnt some link to the JComboBoxes Editor,

4. JComboBox (its model) has nothing to do with JTable (its model) both are living with their own live, if is there proper implementations then XxxTableModel storing only last selected value from JComboBox as Editor
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: How to go about starting to use Java events?
 
Similar Threads
SCJP Logo
Assert stmt in Eclipse
Accessing servlet-config parameter through EL
Dynamic Data Types in Eclipse
JUnit and Cactus using strutstestCase