RFR: 8316146: Open some swing tests 4 [v3]
Alexey Ivanov
aivanov at openjdk.org
Thu Sep 28 16:08:28 UTC 2023
On Tue, 26 Sep 2023 14:34:20 GMT, Alexey Ivanov <aivanov at openjdk.org> wrote:
>> Alisen Chung has updated the pull request incrementally with one additional commit since the last revision:
>>
>> updated tests based on feedback
>
> test/jdk/javax/swing/ToolTipManager/bug5078214.java line 147:
>
>> 145: });
>> 146:
>> 147: }
>
> As I said, there's absolutely no reason to call `GraphicsEnvironment` methods on EDT — these are not Swing components.
>
> There's no reason to store any of these as static fields, they are local variables.
>
> Suggestion:
>
> private static GraphicsConfiguration getGraphicsConfig() {
> GraphicsDevice[] devices = GraphicsEnvironment.getLocalGraphicsEnvironment()
> .getScreenDevices();
> for (GraphicsDevice device : devices) {
> GraphicsConfiguration[] gc = device.getConfigurations();
> for (int i = 0; i < gc.length; i++) {
> insets = Toolkit.getDefaultToolkit().getScreenInsets(gc[i]);
> if (insets.bottom != 0) {
> return gc[i];
> }
> }
> }
> return null;
> }
>
>
> You call this function from the `main` method.
The nested loop could also be enhanced for:
for (GraphicsConfiguration config : device.getConfigurations()) {
insets = Toolkit.getDefaultToolkit().getScreenInsets(config);
if (insets.bottom != 0) {
return config;
}
}
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/15875#discussion_r1340379635
More information about the client-libs-dev
mailing list