Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'JTextField.selectAllOnFocusPolicy always' not working in tables #652

Closed
mwithake opened this issue Feb 22, 2023 · 5 comments
Closed

'JTextField.selectAllOnFocusPolicy always' not working in tables #652

mwithake opened this issue Feb 22, 2023 · 5 comments
Milestone

Comments

@mwithake
Copy link

We have set UIManager.put("TextComponent.selectAllOnFocusPolicy", "always") for textfields.
But this is not working when the component is the editor for a table-cell.

@DevCharly
Copy link
Collaborator

Yes, TextComponent.selectAllOnFocusPolicy is disabled for cell editors since fixing #395 (in FlatLaf 1.6.2).

However, ATM I'm not sure whether the fix is ok.
There is some difference between commit message (mentions JTable.surrendersFocusOnKeystroke)
and changed code (does not use JTable.surrendersFocusOnKeystroke) 😕

I'll have a look...

@DevCharly
Copy link
Collaborator

fixed in commit 2972300

@DevCharly DevCharly added this to the 3.4 milestone Feb 19, 2024
@mwithake
Copy link
Author

mwithake commented Mar 13, 2024

We have tried the new solution with UIManager.put("Table.editorSelectAllOnStartEditing", true), but is not working if you tabbed thru the cells or if the editor is an JFormattedTextField.

@DevCharly
Copy link
Collaborator

We have tried the new solution with UIManager.put("Table.editorSelectAllOnStartEditing", true),

This is not necessary because it is the default.

... but is not working if you tabbed thru the cells

How do you start editing?

... or if the editor is an JFormattedTextField.

Is the selectAll() method invoked?

if( oldEditorComp == null && editorComp instanceof JTextField )
((JTextField)editorComp).selectAll();

@mwithake
Copy link
Author

Sorry for not mentioning this, we have extended JTable so that editing starts automatically for editable cells:
image

selectAll() for JFormattedTextField is invoked, but i seems only for the DisplayFormat, not for the EditFormat

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants