RFR: 8340308: PassFailJFrame: Make rows default to number of lines in instructions

Alexey Ivanov aivanov at openjdk.org
Thu Sep 19 16:57:35 UTC 2024


On Thu, 19 Sep 2024 15:10:55 GMT, Alexander Zvegintsev <azvegint at openjdk.org> wrote:

> As another improvement, we can also consider calculating the default number of columns (based on the widest string?) in a separate issue.

Yes!

I added a comment in JBS:

> This is part of a larger effort for providing better defaults for sizing the instructions which is tracked by [JDK-8328163](https://bugs.openjdk.org/browse/JDK-8328163): *Implement automatic instruction sizing for `PassFailJFrame`*.

I quickly prototyped it in my [8328163-autoSize-passFail](https://github.com/aivanov-jdk/jdk/tree/8328163-autoSize-passFail) branch ([diff to master](https://github.com/openjdk/jdk/compare/master...aivanov-jdk:jdk:8328163-autoSize-passFail)) in March 2024, yet it proved to be not as simple.

I guess if we disable word-wrapping on `JTextArea`, it becomes simpler; yet some tests already depend on word-wrapping. I or anyone else have to come up with a clever heuristics which works good in most cases.

I thought about using something like this: disable word-wrapping and get text dimensions; if the width is too large (how large?), then enable word-wrapping and reduce the width of the text area, recalculate the preferred size again. If the height is too large (how large?), limit it to a value, the instructions are already in `JScrollPane`, yet it's best to avoid scroll bars — seeing all the instruction text is always better compared to having to scroll.

-------------

PR Comment: https://git.openjdk.org/jdk/pull/21039#issuecomment-2361637062


More information about the client-libs-dev mailing list