I'm using a single-row power table where in each column users enter keywords to filter data in another table below it. Normally I do this with the "Text Field" component, but this method of using 2 tables looks cleaner when there are many fields with filters.
The problem I am having is, if a user enters something in the column, it isn't actually edited until they press "Enter" on the keyboard. I would like the edit to happen concurrently with their entry much like how a text field behaves when "defer updates" is disabled. Does anyone know how to do this?
I think you'll hit a fundamental issue with this approach. Java Swing really wants table editing to follow a specific user interaction flow, where a renderer is displaying contents, the user invokes 'editing' mode, the editor displays editing UI to the user, and the user either confirms or cancels the edit which tells the editor to send the change back to the table model.
It's pretty fundamental to the logic/APIs used. I'm not sure you'll be able to change it.
I see you all over the forum, it's an honor to have you reply to one of my posts.
Fortunately the solution you provide in the link I posted is good enough since the query I'm developing this for returns such a large amount of data that we don't want it firing every time a keystroke happens, so we added a button for the user to control when it happens. I can add the stopEdit() script on that. It's too bad though, because I would like to use this approach for other tables where quick updates would run smoother.
Something that would achieve the same result as what I want using text boxes instead (which have the defer update toggle) would be to have the text box width re-size to match a certain column's width in the power table any time the user re-sizes the column. Do you think that can be done reliably, maybe with a system.gui.transform script on a columnAttributes propertyChange?
I'm not quite sure what you mean, to be honest. My expectation would already be that the textbox expands to the same width as the cell it's in. Can you take a screenshot or screen recording of what you're seeing?
As an aside, I spent a few minutes answering (I'm pretty sure) the wrong question, so here's an example of how to use a custom editor for multi-line string editing in a power table: power_table_multiline_editor.zip (11.9 KB)
Like I said, I'm pretty sure it's not what you actually want, but maybe it's useful to you or somebody anyways
I also was playing around with what I described and it actually worked really well. I should have tried this first! Here is the example of what I was describing.
I have a power table with test data in it and a text box sitting on top of the headers of the power table. I want the text box to remain the same width as the first column header when the column is re-sized, so I put this script in the propertyChange script of the power table:
if event.propertyName == 'defaultColumnView':
textfield1 = event.source.parent.getComponent('Text Field')
tableProps = event.source.defaultColumnView
## Uncomment and use to find the indices of the relevant columns and widths
# for index, attribute in enumerate(tableProps.split('\t')):
# print(index, attribute)
column1Width = str(int(tableProps.split('\t')) + 1)
I added " + 1" to the column width because the value returned for the column size didn't include the width of the border (which is 1 pixel).
I hope my code makes more sense than my long paragraphs describing what I'm trying to do (sorry!) I appreciate your help with this! I probably wouldn't have tried the text box method if you hadn't discouraged me from editing a power table with updates on keystrokes.