|
1 | 1 | /* |
2 | | - * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. |
| 2 | + * Copyright (c) 2022, 2025, Oracle and/or its affiliates. All rights reserved. |
3 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 | 4 | * |
5 | 5 | * This code is free software; you can redistribute it and/or modify it |
|
34 | 34 | import java.util.Arrays; |
35 | 35 | import java.util.Locale; |
36 | 36 | import java.util.concurrent.atomic.AtomicReference; |
37 | | -import java.util.function.Predicate; |
38 | 37 |
|
39 | 38 | import javax.swing.AbstractButton; |
40 | 39 | import javax.swing.JFileChooser; |
|
52 | 51 | * @requires (os.family == "linux") |
53 | 52 | * @summary Verifies if the size of an empty file is shown as 0.0 KB |
54 | 53 | * as well as checks the displayed file sizes are rounded up |
| 54 | + * @library /javax/swing/regtesthelpers |
| 55 | + * @build Util |
55 | 56 | * @run main FileSizeCheck |
56 | 57 | */ |
57 | 58 | public class FileSizeCheck { |
@@ -228,31 +229,15 @@ private static void clickDetails() { |
228 | 229 | } |
229 | 230 |
|
230 | 231 | private static AbstractButton findDetailsButton(final Container container) { |
231 | | - Component result = findComponent(container, |
| 232 | + Component result = Util.findComponent(container, |
232 | 233 | c -> c instanceof JToggleButton button |
233 | 234 | && "Details".equals(button.getToolTipText())); |
234 | 235 | return (AbstractButton) result; |
235 | 236 | } |
236 | 237 |
|
237 | 238 | private static JTable findTable(final Container container) { |
238 | | - Component result = findComponent(container, |
239 | | - c -> c instanceof JTable); |
| 239 | + Component result = Util.findComponent(container, |
| 240 | + c -> c instanceof JTable); |
240 | 241 | return (JTable) result; |
241 | 242 | } |
242 | | - |
243 | | - private static Component findComponent(final Container container, |
244 | | - final Predicate<Component> predicate) { |
245 | | - for (Component child : container.getComponents()) { |
246 | | - if (predicate.test(child)) { |
247 | | - return child; |
248 | | - } |
249 | | - if (child instanceof Container cont && cont.getComponentCount() > 0) { |
250 | | - Component result = findComponent(cont, predicate); |
251 | | - if (result != null) { |
252 | | - return result; |
253 | | - } |
254 | | - } |
255 | | - } |
256 | | - return null; |
257 | | - } |
258 | 243 | } |
0 commit comments