RFR: 8357176: java.awt javadoc code examples still use Applet API [v2]

Phil Race prr at openjdk.org
Tue May 20 21:58:52 UTC 2025


On Tue, 20 May 2025 21:17:22 GMT, Sergey Bylokhov <serb at openjdk.org> wrote:

>> Phil Race has updated the pull request incrementally with one additional commit since the last revision:
>> 
>>   8357176
>
> src/java.desktop/share/classes/java/awt/GridLayout.java line 50:
> 
>> 48:  *
>> 49:  *     EventQueue.invokeAndWait(() -> {
>> 50:  *        Frame frame = new Frame("GridLayout");
> 
> I would like to bring this to the discussion not necessarily suggesting any changes. I noticed that the example uses a "frame", while the description above refers to a "window" it might be worth unification. Also, regarding invokeAndWait: it’s not strictly necessary here since this is AWT but it does not break anything. However, I wonder if it’s worth discussing the use of invokeAndWait vs invokeLater. In tests, we usually prefer invokeAndWait because we need to wait for the action to complete, but in applications invokeLater should work fine.

A Frame (the java class) creates a window (the desktop concept). I would not want to promote the java type Frame to mean the concept.
Regarding invokeAndWait vs invokeLater, either is fine in this case and main has nothing else to do whilst waiting and is the safest default.
I pondered whether to do either in this simple case, but we do generally these days recommend this pattern even for AWT as Swing classes may be used to implement AWT .. and if I did not I guarantee someone would have said I should use it ! Whether or not it matters in this case.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/25278#discussion_r2098939094


More information about the client-libs-dev mailing list