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

Alexey Ivanov aivanov at openjdk.org
Wed May 21 16:31:58 UTC 2025


On Tue, 20 May 2025 22:09:37 GMT, Phil Race <prr at openjdk.org> wrote:

>> Update the some code examples and accompanying images to no longer mention or display as applets.
>
> Phil Race has updated the pull request incrementally with one additional commit since the last revision:
> 
>   8357176

I still have some minor nits.

src/java.desktop/share/classes/java/awt/BorderLayout.java line 102:

> 100:  * The code for this program is as follows:
> 101:  *
> 102:  * <hr>

Suggestion:


Drop the horizontal line. It separates the code from the paragraph that introduces it.

src/java.desktop/share/classes/java/awt/BorderLayout.java line 115:

> 113:  *     EventQueue.invokeAndWait(() -> {
> 114:  *        Frame frame = new Frame("BorderLayout");
> 115:  *        frame.setLayout(new BorderLayout());

Suggestion:

 * public class BorderLayoutExample {
 *
 *     public static void main(String[] args) throws Exception {
 *         EventQueue.invokeAndWait(() -> {
 *             Frame frame = new Frame("BorderLayout");
 *             frame.setLayout(new BorderLayout());

I suggest following the standard indentation of 4 spaces to align with the recommended Java code style and dropping the blank line inside the `main` method.

Is there any particular reason for using `invokeAndWait` instead of `invokeLater`? Most Java UI tutorials use `invokeLater`.

(In the tests, we have to use `invokeAndWait`.)

src/java.desktop/share/classes/java/awt/FlowLayout.java line 63:

> 61:  * Here is the code for this program:
> 62:  *
> 63:  * <hr>

Suggestion:


I suggest dropping the horizontal line from all the sample code.

src/java.desktop/share/classes/java/awt/FlowLayout.java line 64:

> 62:  *
> 63:  * <hr>
> 64:  * {@snippet  lang='java':

Suggestion:

 * {@snippet lang='java':

Not really an issue, however, other instances have just one space.

src/java.desktop/share/classes/java/awt/FlowLayout.java line 75:

> 73:  *
> 74:  *     EventQueue.invokeAndWait(() -> {
> 75:  *        Frame frame = new Frame("FlowLayout");

The same comment: let's follow the standard Java code style and indent blocks by 4 spaces.

Here, the `main` method declaration and `EventQueue.invokeAndWait` are indented by 2 spaces, but the body of the lambda expression is indented by 4 spaces. This is inconsistent.

src/java.desktop/share/classes/java/awt/GridBagLayout.java line 279:

> 277:  * Here is the code that implements the example shown above:
> 278:  *
> 279:  * <hr>

Suggestion:

src/java.desktop/share/classes/java/awt/GridBagLayout.java line 287:

> 285:  * import java.awt.GridBagLayout;
> 286:  *
> 287:  * public class GridBagLayoutExample {

This sample indents each code block by 4 spaces, which is good.

src/java.desktop/share/classes/java/awt/GridLayout.java line 40:

> 38:  * <hr>
> 39:  * {@snippet lang='java':
> 40:  * <pre>

Suggestion:

 * {@snippet lang='java':

`<pre>` is inside the sample code.

src/java.desktop/share/classes/java/awt/GridLayout.java line 51:

> 49:  *
> 50:  *     EventQueue.invokeAndWait(() -> {
> 51:  *        Frame frame = new Frame("GridLayout");

Let's indent the code by 4 spaces.

I'm also for removing the blank line that starts the `main` method.

src/java.desktop/share/classes/java/awt/MediaTracker.java line 70:

> 68:  * Here is an example of using {@code MediaTracker}:
> 69:  *
> 70:  * <hr>

Suggestion:

src/java.desktop/share/classes/java/awt/MediaTracker.java line 117:

> 115:  *          animator = new Thread(this);
> 116:  *          animator.start();
> 117:  *     }

Suggestion:

 *      }

Correct the indentation.

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

Changes requested by aivanov (Reviewer).

PR Review: https://git.openjdk.org/jdk/pull/25278#pullrequestreview-2858047334
PR Review Comment: https://git.openjdk.org/jdk/pull/25278#discussion_r2100501264
PR Review Comment: https://git.openjdk.org/jdk/pull/25278#discussion_r2100498882
PR Review Comment: https://git.openjdk.org/jdk/pull/25278#discussion_r2100697034
PR Review Comment: https://git.openjdk.org/jdk/pull/25278#discussion_r2100714553
PR Review Comment: https://git.openjdk.org/jdk/pull/25278#discussion_r2100701896
PR Review Comment: https://git.openjdk.org/jdk/pull/25278#discussion_r2100705020
PR Review Comment: https://git.openjdk.org/jdk/pull/25278#discussion_r2100707123
PR Review Comment: https://git.openjdk.org/jdk/pull/25278#discussion_r2100683735
PR Review Comment: https://git.openjdk.org/jdk/pull/25278#discussion_r2100712282
PR Review Comment: https://git.openjdk.org/jdk/pull/25278#discussion_r2100712613
PR Review Comment: https://git.openjdk.org/jdk/pull/25278#discussion_r2100718917


More information about the client-libs-dev mailing list