JShell EditPad is cutoff by default
David Alayachew
davidalayachew at gmail.com
Mon Aug 18 04:48:47 UTC 2025
And look at the documentation --
https://docs.oracle.com/en/java/javase/24/docs/api/java.desktop/java/awt/Window.html#setLocationRelativeTo(java.awt.Component)
It says this.
> If the component is null, or the GraphicsConfiguration
> associated with this component is null, the window is
> placed in the center of the screen. The center point
> can be obtained with the
> GraphicsEnvironment.getCenterPoint
<https://docs.oracle.com/en/java/javase/24/docs/api/java.desktop/java/awt/GraphicsEnvironment.html#getCenterPoint()>
method.
This confirms what I am saying -- that it normally sets it in the center of
the screen.
As for which solution is better, the developer in question probably did
intend for it to be centered, considering the function and parameter used.
So probably better to stick with their original intent for now, until given
reason not to.
Here is my pull request -- https://github.com/openjdk/jdk/pull/26814
On Mon, Aug 18, 2025 at 12:22 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/80ab8f8e/attachment-0001.htm>
More information about the compiler-dev
mailing list