kirill-grouchnikov / substance

A modern and high-performant Swing look-and-feel library
164 stars 109 forks source link

Using the same border for JTextField and JTextArea/JScrollPane? #83

Closed utybo closed 6 years ago

utybo commented 6 years ago

Here is my problem : the Text Area's borders are not really visible out of the box, and look out of place when put beside JTextFields.

So I tried to add the same border from JTextField Substance uses : SubstanceTextComponentBorder. While it works fine when applying it to JTextAreas themselves, it's not practical as it is unusable with scroll panes. Moreover, it does not work when applying the border to JScrollPanes which have text areas as their viewport. (the transition when the cursor enters the JTextArea does not happen).

I have tried hacking my way around this after seeing how the border seems to handle transitions

scrollPane.putClientProperty(SubstanceCoreUtilities.TEXT_COMPONENT_AWARE,
                new SubstanceCoreUtilities.TextComponentAware<JScrollPane>()
                {
                    @Override
                    public JTextComponent getTextComponent(JScrollPane jsp)
                    {
                        return textArea;
                    }
                });

This does not work either.

Is there any way to do this?

kirill-grouchnikov commented 6 years ago

TextArea's default border is invisible / margin by design. JScrollPane default border is invisible by design. SubstanceTextComponentBorder is internal implementation detail. SubstanceCoreUtilities is internal implementation detail.

If you want a custom border for this particular configuration, you will need your own implementation of that that uses official public APIs in the .api package.

utybo commented 6 years ago

Alright, thank you, I'll see what I can do on my side