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

TextField.selectAllOnFocusPolicy not working #961

Open
mlaggner opened this issue Jan 21, 2025 · 3 comments
Open

TextField.selectAllOnFocusPolicy not working #961

mlaggner opened this issue Jan 21, 2025 · 3 comments

Comments

@mlaggner
Copy link

According to JTextField selects all text the first time it is set visible. and https://www.formdev.com/flatlaf/client-properties/#JTextField the default behaviour of focusing a textfield would be to select all text (like most UI frameworks do).

I could not make that working in my app - but this is not even working in your demo. I suspect it isn't working at all?

@DevCharly
Copy link
Collaborator

Hmm, for me it works fine 😕
What OS and Java version do you use?

How do you focus the textfield?
This works only if you use the TAB key to move focus to textfield.
If you click into a textfield, the caret is placed at the clicked location and no text is selected.

@mlaggner
Copy link
Author

Okay, good to know. If you never ever clicked into that textfield via mouse (and only used tab) this works as expected. But if you once clicked into that textfield and later on jump in via tab again, it does not work.

Looks like I need to live with that (or find a workaround in my app).

Can I ask another question - do you know by heart if that can be enabled easily for spinners too?

@mlaggner
Copy link
Author

Okay, got it working for a JSpinner by subclassing this and setting the JTextField.selectAllOnFocusPolicy to always only for tabbing in, but I did not find a way to set selectAllOnMouseClick on component level (only globally). Did I miss something?

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