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

Read-only (non-editable) JTextArea – background color not updated #147

Closed
stanio opened this issue Aug 2, 2020 · 7 comments
Closed

Read-only (non-editable) JTextArea – background color not updated #147

stanio opened this issue Aug 2, 2020 · 7 comments
Milestone

Comments

@stanio
Copy link

stanio commented Aug 2, 2020

Not sure if this could be considered a bug as I'm seeing such behavior with at least one other L&F – Nimbus:

text-components

The background color of non-editable text-area doesn't seem to reflect the actual background color used.

        JTextArea textArea = new JTextArea();
        textArea.getBackground(); // editable background
        textArea.setEditable(false);
        textArea.getBackground(); // non-editable background

Using FlatLaf 0.38.

@DevCharly
Copy link
Collaborator

The reason for this is a "temporary" workaround in Swing:

https://github.com/openjdk/jdk/blob/1f5e21a16e1bb9a7291b38cedf4269717bbbe428/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicTextUI.java#L228-L239

@stanio
Copy link
Author

stanio commented Aug 2, 2020

Thanks for the explanation and I'm closing this.

@stanio stanio closed this as completed Aug 2, 2020
@stanio
Copy link
Author

stanio commented Aug 3, 2020

It's funny though, the JGoodies Plastic L&F seems to have the background color of read-only text-area updated.

@DevCharly
Copy link
Collaborator

Yes, there is some code in PlasticTextAreaUI that does basically the same as in BasicTextUI.updateBackground() to update the background color.

Do you think FlatLaf should do the same?

I wonder how did you discover this inconsistency?

@DevCharly DevCharly reopened this Aug 3, 2020
@stanio
Copy link
Author

stanio commented Aug 3, 2020

I don't think FlatLaf should go the extra mile if there's no enough demand for it. I've discovered it while looking into:

which is not text-area related, but text-pane. I've just compiled small sample to compare the L&F of standard text components.

DevCharly added a commit that referenced this issue Aug 25, 2020
…te changes in the same way as Swing does it for all other text components (issue #147)
@DevCharly
Copy link
Collaborator

Has reviewed all text component UI delegates. Background painting in FlatTextAreaUI was very different to what is done in other text component UI delegates. So to unify text component background painting and to have consistent behavior of background color across all text components, FlatTextAreaUI now updates the background color property if enabled or editable state changes in the same way as Swing does it for all other text components.

@DevCharly DevCharly added this to the 0.41 milestone Aug 25, 2020
@stanio
Copy link
Author

stanio commented Aug 26, 2020

Thank you for the extra effort!

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