RFR: 8294148: Support JSplitPane for instructions and test UI
Harshitha Onkar
honkar at openjdk.org
Wed Feb 14 18:51:02 UTC 2024
On Wed, 14 Feb 2024 13:22:48 GMT, Alexey Ivanov <aivanov at openjdk.org> wrote:
> This enhancement adds three methods to `PassFailJFrame.Builder`:
>
> 1. **`splitUIRight`** to display test UI to the right of the instructions;
> 2. **`splitUIBottom`** to display test UI to the bottom of the instructions;
> 3. `splitUI`: a convenience method for a default split orientation, currently defaults to `splitUIRight`.
>
> If UI of a test is simple, it's reasonable to embed the test UI into the instruction UI. In this case, there's only one frame the tester will be interacting with.
>
> The implementation is similar to that of `testUI` provided under [JDK-8294156](https://bugs.openjdk.org/browse/JDK-8294156). The `splitUI-` method accept a reference to `PanelCreator` interface. Instead of creating an entire frame, you create only a component, usually a `JPanel` or `Box`, which contains all the test UI.
>
> For example,
>
>
> PassFailJFrame.builder()
> .instructions("Instructions for the test")
> .splitUI(() -> {
> JPanel panel = new JPanel();
> panel.add(new JButton("Click Me"));
> return panel;
> })
> .build()
> .awaitAndCheck();
>
>
> In addition to it, there's an advanced `testUI` method which accepts `PanelCreator`; in this case the test UI is hosted in `JDialog` with the instruction frame being its owner. Because the test UI is in a modeless owned dialog, it always displays above the instruction frame, switch to the test app brings up both the instructions and test UI. I don't expect it'd be used often, yet it's easy to implement.
test/jdk/java/awt/regtesthelpers/PassFailJFrame.java line 1229:
> 1227: * @throws IllegalArgumentException if {panelCreator} is {@code null}
> 1228: */
> 1229: public Builder splitUI(PanelCreator panelCreator) {
Suggestion:
public Builder splitUI(PanelCreator panelCreator, int splitUIOrientation ) {
Would it be easier if we use `splitUIOrientation` or an enum similar to [Position](https://github.com/openjdk/jdk/blob/b823fa44508901a6bf39795ab18991d055a71b4e/test/jdk/java/awt/regtesthelpers/PassFailJFrame.java#L191) to determine the split than have three different methods - `splitUI, splitUIRight & splitUIBottom`?
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/17845#discussion_r1489920151
More information about the client-libs-dev
mailing list