<div dir="ltr"><div class="gmail_default" style="font-family:monospace">And look at the documentation -- <a href="https://docs.oracle.com/en/java/javase/24/docs/api/java.desktop/java/awt/Window.html#setLocationRelativeTo(java.awt.Component)" target="_blank">https://docs.oracle.com/en/java/javase/24/docs/api/java.desktop/java/awt/Window.html#setLocationRelativeTo(java.awt.Component)</a></div><div class="gmail_default" style="font-family:monospace"><br></div><div class="gmail_default" style="font-family:monospace">It says this.</div><div class="gmail_default" style="font-family:monospace"><br></div><div class="gmail_default" style="font-family:monospace">> If the component is <code>null</code>, or the <code>
GraphicsConfiguration</code> </div><div class="gmail_default" style="font-family:monospace">> associated with this component is
<code>null</code>, the window is</div><div class="gmail_default" style="font-family:monospace">> placed in the center of the
screen. The center point</div><div class="gmail_default" style="font-family:monospace">> can be obtained with the</div><div class="gmail_default" style="font-family:monospace">> <a href="https://docs.oracle.com/en/java/javase/24/docs/api/java.desktop/java/awt/GraphicsEnvironment.html#getCenterPoint()" target="_blank"><code>GraphicsEnvironment.getCenterPoint</code></a> method.</div><div class="gmail_default" style="font-family:monospace"><br></div><div class="gmail_default" style="font-family:monospace">This confirms what I am saying -- that it normally sets it in the center of the screen.</div><div class="gmail_default" style="font-family:monospace"><br></div><div class="gmail_default" style="font-family:monospace">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.</div><div class="gmail_default" style="font-family:monospace"><br></div><div class="gmail_default" style="font-family:monospace">Here is my pull request -- <a href="https://github.com/openjdk/jdk/pull/26814">https://github.com/openjdk/jdk/pull/26814</a></div><div class="gmail_default" style="font-family:monospace"><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Aug 18, 2025 at 12:22 AM David Alayachew <<a href="mailto:davidalayachew@gmail.com" target="_blank">davidalayachew@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div style="font-family:monospace" class="gmail_default">Woah, I found something even deeper.</div><div style="font-family:monospace" class="gmail_default"><br></div><div style="font-family:monospace" class="gmail_default">Look at the order of the commands. First, we set location, THEN we set the size.</div><div style="font-family:monospace" class="gmail_default"><br></div><div style="font-family:monospace" class="gmail_default">Reverse the 2, and then it works!</div><div style="font-family:monospace" class="gmail_default"><br></div><div style="font-family:monospace" class="gmail_default">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.</div><div style="font-family:monospace" class="gmail_default"><br></div><div style="font-family:monospace" class="gmail_default">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?</div><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sun, Aug 17, 2025 at 11:46 PM Chen Liang <<a href="mailto:chen.l.liang@oracle.com" target="_blank">chen.l.liang@oracle.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div>
<div dir="ltr">
<div style="font-family:"Calibri Light","Helvetica Light",sans-serif;font-size:12pt;color:rgb(0,0,0)">
Hi David, thank you so much for your report!</div>
<div style="font-family:"Calibri Light","Helvetica Light",sans-serif;font-size:12pt;color:rgb(0,0,0)">
<br>
</div>
<div style="font-family:"Calibri Light","Helvetica Light",sans-serif;font-size:12pt;color:rgb(0,0,0)">
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
<a href="https://bugs.openjdk.org/browse/JDK-8365643" target="_blank">https://bugs.openjdk.org/browse/JDK-8365643</a> to track this issue. (Meanwhile it doesn't happen on Ubuntu)</div>
<div style="font-family:"Calibri Light","Helvetica Light",sans-serif;font-size:12pt;color:rgb(0,0,0)">
<br>
</div>
<div style="font-family:"Calibri Light","Helvetica Light",sans-serif;font-size:12pt;color:rgb(0,0,0)">
I think the problem lies in this line - <a href="https://github.com/openjdk/jdk/blob/bd65d483df4742bb7ce79b613f10f70a45117f84/src/jdk.editpad/share/classes/jdk/editpad/EditPad.java#L92" target="_blank">
https://github.com/openjdk/jdk/blob/bd65d483df4742bb7ce79b613f10f70a45117f84/src/jdk.editpad/share/classes/jdk/editpad/EditPad.java#L92</a></div>
<div style="font-family:"Calibri Light","Helvetica Light",sans-serif;font-size:12pt;color:rgb(0,0,0)">
Since you suggested the solution, can you try replacing that call with setLocationByPlatform and see if this fixes your problem on Windows?</div>
<div style="font-family:"Calibri Light","Helvetica Light",sans-serif;font-size:12pt;color:rgb(0,0,0)">
<br>
</div>
<div style="font-family:"Calibri Light","Helvetica Light",sans-serif;font-size:12pt;color:rgb(0,0,0)">
If this works for you, feel free to contribute a patch to OpenJDK upstream.</div>
<div style="font-family:"Calibri Light","Helvetica Light",sans-serif;font-size:12pt;color:rgb(0,0,0)">
<br>
</div>
<div style="font-family:"Calibri Light","Helvetica Light",sans-serif;font-size:12pt;color:rgb(0,0,0)">
Kind regards, Chen Liang</div>
<div style="font-family:"Calibri Light","Helvetica Light",sans-serif;font-size:12pt;color:rgb(0,0,0)">
<br>
</div>
<div style="font-family:"Calibri Light","Helvetica Light",sans-serif;font-size:12pt;color:rgb(0,0,0)">
<br>
</div>
<div id="m_-7791538054375258968m_8342481055441068589m_-3280908527273591907m_643434816977966052appendonsend"></div>
<hr style="display:inline-block;width:98%">
<div id="m_-7791538054375258968m_8342481055441068589m_-3280908527273591907m_643434816977966052divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size:11pt" color="#000000"><b>From:</b> compiler-dev <<a href="mailto:compiler-dev-retn@openjdk.org" target="_blank">compiler-dev-retn@openjdk.org</a>> on behalf of David Alayachew <<a href="mailto:davidalayachew@gmail.com" target="_blank">davidalayachew@gmail.com</a>><br>
<b>Sent:</b> Sunday, August 17, 2025 9:39 PM<br>
<b>To:</b> compiler-dev <<a href="mailto:compiler-dev@openjdk.org" target="_blank">compiler-dev@openjdk.org</a>><br>
<b>Subject:</b> JShell EditPad is cutoff by default</font>
<div> </div>
</div>
<div>
<div dir="ltr">
<div style="font-family:monospace">Hello <a id="m_-7791538054375258968m_8342481055441068589m_-3280908527273591907m_643434816977966052x_plusReplyChip-0" href="mailto:compiler-dev@openjdk.org" target="_blank">@compiler-dev</a>,</div>
<div style="font-family:monospace"><br>
</div>
<div style="font-family:monospace">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.</div>
<div style="font-family:monospace"><br>
</div>
<div style="font-family:monospace">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?</div>
<div style="font-family:monospace"><br>
</div>
<div style="font-family:monospace">This should be incredibly easy to recreate. I have tested this on 4 different computers, and all have the same behaviour.</div>
<div style="font-family:monospace"><br>
</div>
<div style="font-family:monospace">Thank you for your time and attention.</div>
<div style="font-family:monospace">David Alayachew</div>
</div>
</div>
</div>
</div></blockquote></div>
</blockquote></div>