JShell EditPad is cutoff by default

Christian Stein sormuras at gmail.com
Mon Aug 18 07:50:28 UTC 2025


I approved PR https://github.com/openjdk/jdk/pull/26814 because I can
confirm that the current order of commands results in a centered upper-left
corner of the edit window. (Only Windows?)

Moving the `jframe.setLocationRelativeTo(null);` after the
`jframe.setSize(800, 600);` (and still before `jframe.setVisible(true);`)
solves the problem.

On Mon, Aug 18, 2025 at 6:23 AM David Alayachew <davidalayachew at gmail.com>
wrote:

> Woah, I found something even deeper.
>
> Look at the order of the commands. First, we set location, THEN we set the
> size.
>
> Reverse the 2, and then it works!
>
> I am 99.999999% sure that, what is happening is Swing tries to center the
> window when the size defaults to (0, 0), which would be the center of the
> screen. And then, when we set the size, it keeps its location, but expands
> down and right, causing the problem we see.
>
> So, I think a cleaner solution would instead be to change the order of the
> 2 commands. Is that ok with you? Can you test it locally?
>
>
> On Sun, Aug 17, 2025 at 11:46 PM Chen Liang <chen.l.liang at oracle.com>
> wrote:
>
>> Hi David, thank you so much for your report!
>>
>> Indeed, I can reproduce this issue on my windows device with a different
>> resolution - the 3 bottom buttons are out of the screen. I have created
>> https://bugs.openjdk.org/browse/JDK-8365643 to track this issue.
>> (Meanwhile it doesn't happen on Ubuntu)
>>
>> I think the problem lies in this line -
>> https://github.com/openjdk/jdk/blob/bd65d483df4742bb7ce79b613f10f70a45117f84/src/jdk.editpad/share/classes/jdk/editpad/EditPad.java#L92
>> Since you suggested the solution, can you try replacing that call with
>> setLocationByPlatform and see if this fixes your problem on Windows?
>>
>> If this works for you, feel free to contribute a patch to OpenJDK
>> upstream.
>>
>> Kind regards, Chen Liang
>>
>>
>> ------------------------------
>> *From:* compiler-dev <compiler-dev-retn at openjdk.org> on behalf of David
>> Alayachew <davidalayachew at gmail.com>
>> *Sent:* Sunday, August 17, 2025 9:39 PM
>> *To:* compiler-dev <compiler-dev at openjdk.org>
>> *Subject:* JShell EditPad is cutoff by default
>>
>> Hello @compiler-dev <compiler-dev at openjdk.org>,
>>
>> On my Windows 11 laptop, when I open up jshell and type /edit, the edit
>> pad that pops up is ALWAYS cutoff at the bottom right of my screen. Please
>> note, I have a 1920x1080 monitor and a computer set to that resolution.
>>
>> It's annoying, and a bad user experience. Wouldn't it make more sense to
>> do something similar to Swing's setLocationByPlatform()? Or better yet,
>> just pick a sensible default?
>>
>> This should be incredibly easy to recreate. I have tested this on 4
>> different computers, and all have the same behaviour.
>>
>> Thank you for your time and attention.
>> David Alayachew
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/compiler-dev/attachments/20250818/e0f96182/attachment.htm>


More information about the compiler-dev mailing list