<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body style="overflow-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;">
<span style="font-size: 14px;">Hi John,</span>
<div><span style="font-size: 14px;"><br>
</span></div>
<div><span style="font-size: 14px;">   This looks like a user code issue and not a JavaFX bug.</span></div>
<div><span style="font-size: 14px;">   Most of the vertical scrollbar issues that you have mentioned get fixed by adding a call to "super.updateItem(image, empty);" as a first call in the cell factory method "<span style="white-space: pre; background-color: rgb(255, 255, 255);">protected
 void </span><span style="white-space: pre; background-color: rgb(255, 255, 255);">updateItem</span><span style="white-space: pre; background-color: rgb(255, 255, 255);">(</span><span style="white-space: pre; background-color: rgb(255, 255, 255);">Image
</span><span style="white-space: pre; background-color: rgb(255, 255, 255);">image,
</span><span style="white-space: pre; background-color: rgb(255, 255, 255);">boolean
</span><span style="white-space: pre; background-color: rgb(255, 255, 255);">empty)</span><span style="white-space: pre;">”</span></span></div>
<div><br>
</div>
<div><span style="white-space: pre; background-color: rgb(255, 255, 255); font-size: 14px;">I am seeing an exception when I scroll fully down and then scroll up by clicking empty area on the vertical scrollbar. This looks like a separate issue though.</span></div>
<div><span style="white-space: pre; background-color: rgb(255, 255, 255); font-size: 14px;"><br>
</span></div>
<div><span style="white-space: pre; background-color: rgb(255, 255, 255); font-size: 14px;">Regards,</span></div>
<div><span style="white-space: pre; background-color: rgb(255, 255, 255); font-size: 14px;">Ajit</span></div>
<div style="font-size: 12pt; background-color: rgb(255, 255, 255); color: rgb(8, 8, 8); font-family: "JetBrains Mono", monospace; white-space: pre;">
<br>
</div>
<div>
<div><br>
<blockquote type="cite">
<div>On 12-Jul-2023, at 5:18 AM, Andy Goryachev <andy.goryachev@oracle.com> wrote:</div>
<br class="Apple-interchange-newline">
<div>
<div class="WordSection1" style="page: WordSection1; caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;">
<div style="margin: 0in; font-size: 10pt; font-family: Calibri, sans-serif;"><span style="font-size: 11pt; font-family: "Iosevka Fixed SS16";">Thank you for the code sample, John!<o:p></o:p></span></div>
<div style="margin: 0in; font-size: 10pt; font-family: Calibri, sans-serif;"><span style="font-size: 11pt; font-family: "Iosevka Fixed SS16";"><o:p> </o:p></span></div>
<div style="margin: 0in; font-size: 10pt; font-family: Calibri, sans-serif;"><span style="font-size: 11pt; font-family: "Iosevka Fixed SS16";">Had to replace loading from https:// to a local file://, but I do see some of the issues you've mentioned (on macOS):<o:p></o:p></span></div>
<div style="margin: 0in; font-size: 10pt; font-family: Calibri, sans-serif;"><span style="font-size: 11pt; font-family: "Iosevka Fixed SS16";">2), 5), and 6).<o:p></o:p></span></div>
<div style="margin: 0in; font-size: 10pt; font-family: Calibri, sans-serif;"><span style="font-size: 11pt; font-family: "Iosevka Fixed SS16";"><o:p> </o:p></span></div>
<div style="margin: 0in; font-size: 10pt; font-family: Calibri, sans-serif;"><span style="font-size: 11pt; font-family: "Iosevka Fixed SS16";">There is also a new issue:<o:p></o:p></span></div>
<div style="margin: 0in; font-size: 10pt; font-family: Calibri, sans-serif;"><span style="font-size: 11pt; font-family: "Iosevka Fixed SS16";"><o:p> </o:p></span></div>
<div style="margin: 0in; font-size: 10pt; font-family: Calibri, sans-serif;"><span style="font-size: 11pt; font-family: "Iosevka Fixed SS16";">7) when the top of the cell is outside of the view area, the image is not shown at all (but the cell is sized correctly).<o:p></o:p></span></div>
<div style="margin: 0in; font-size: 10pt; font-family: Calibri, sans-serif;"><span style="font-size: 11pt; font-family: "Iosevka Fixed SS16";"><o:p> </o:p></span></div>
<div style="margin: 0in; font-size: 10pt; font-family: Calibri, sans-serif;"><span style="font-size: 11pt; font-family: "Iosevka Fixed SS16";">All this is indeed weird.  Looks like the time is right to create a bug, unless it's this one:<o:p></o:p></span></div>
<div style="margin: 0in; font-size: 10pt; font-family: Calibri, sans-serif;"><span style="font-size: 11pt; font-family: "Iosevka Fixed SS16";"><o:p> </o:p></span></div>
<table class="MsoNormalTable" border="0" cellspacing="0" cellpadding="0" width="1440" style="width: 15in; background-color: white; border-collapse: collapse;">
<tbody>
<tr>
<td width="16" nowrap="" valign="top" style="width: 12pt; border-style: none none solid; border-bottom-width: 1pt; border-bottom-color: rgb(193, 199, 208); background-color: rgb(235, 236, 240); padding: 3.75pt 7.5pt;">
<p class="MsoNormal" style="margin: 0in 0in 6pt; font-size: 10pt; font-family: Calibri, sans-serif;">
<span style="font-size: 10.5pt; font-family: Arial, sans-serif; color: rgb(23, 43, 77);"><a href="https://bugs.openjdk.org/browse/JDK-8090254" style="color: blue; text-decoration: underline;"><span style="color: rgb(0, 82, 204);">JDK-8090254</span></a><o:p></o:p></span></p>
</td>
<td valign="top" style="border-style: none none solid; border-bottom-width: 1pt; border-bottom-color: rgb(193, 199, 208); background-color: rgb(235, 236, 240); padding: 3.75pt 7.5pt;">
<div style="margin: 0in; font-size: 10pt; font-family: Calibri, sans-serif;"><span style="font-size: 10.5pt; font-family: Arial, sans-serif; color: rgb(23, 43, 77);"><a href="https://bugs.openjdk.org/browse/JDK-8090254" style="color: blue; text-decoration: underline;"><span style="color: rgb(0, 82, 204);">[ListView]
 page up/down navigation doesn't work, when items are large (again!)</span></a><o:p></o:p></span></div>
</td>
</tr>
</tbody>
</table>
<div style="margin: 0in; font-size: 10pt; font-family: Calibri, sans-serif;"><span style="font-size: 11pt; font-family: "Iosevka Fixed SS16";"><o:p> </o:p></span></div>
<div style="margin: 0in; font-size: 10pt; font-family: Calibri, sans-serif;"><span style="font-size: 11pt; font-family: "Iosevka Fixed SS16";">-andy<o:p></o:p></span></div>
<div style="margin: 0in; font-size: 10pt; font-family: Calibri, sans-serif;"><span style="font-size: 11pt; font-family: "Iosevka Fixed SS16";"><o:p> </o:p></span></div>
<div style="margin: 0in; font-size: 10pt; font-family: Calibri, sans-serif;"><span style="font-size: 11pt; font-family: "Iosevka Fixed SS16";"><o:p> </o:p></span></div>
<div style="margin: 0in; font-size: 10pt; font-family: Calibri, sans-serif;"><span style="font-size: 11pt; font-family: "Iosevka Fixed SS16";"><o:p> </o:p></span></div>
<div id="mail-editor-reference-message-container">
<div>
<div style="border-style: solid none none; border-top-width: 1pt; border-top-color: rgb(181, 196, 223); padding: 3pt 0in 0in;">
<p class="MsoNormal" style="margin: 0in 0in 12pt; font-size: 10pt; font-family: Calibri, sans-serif;">
<b><span style="font-size: 12pt;">From:<span class="Apple-converted-space"> </span></span></b><span style="font-size: 12pt;">openjfx-dev <openjfx-dev-retn@openjdk.org> on behalf of John Hendrikx <john.hendrikx@gmail.com><br>
<b>Date:<span class="Apple-converted-space"> </span></b>Tuesday, July 11, 2023 at 16:34<br>
<b>To:<span class="Apple-converted-space"> </span></b>openjfx-dev@openjdk.org <openjfx-dev@openjdk.org><br>
<b>Subject:<span class="Apple-converted-space"> </span></b>Re: ListView with ImageViews for cells very bugged?<o:p></o:p></span></p>
</div>
<p>I said I'd do it tomorrow, but here is a full example anyway with pre-loaded images, and without external dependencies:<o:p></o:p></p>
<p><o:p> </o:p></p>
<p>package org.int4.sdui.ui;<br>
<br>
import javafx.application.Application;<br>
import javafx.scene.Scene;<br>
import javafx.scene.control.Button;<br>
import javafx.scene.control.ListCell;<br>
import javafx.scene.control.ListView;<br>
import javafx.scene.control.TextArea;<br>
import javafx.scene.image.Image;<br>
import javafx.scene.image.ImageView;<br>
import javafx.scene.layout.HBox;<br>
import javafx.scene.layout.Priority;<br>
import javafx.scene.layout.VBox;<br>
import javafx.stage.Stage;<br>
<br>
public class Main2 {<br>
<br>
  public static void main(String[] args) {<br>
    Application.launch(UI.class, args);<br>
  }<br>
<br>
  public static class UI extends Application {<br>
<br>
    @Override<br>
    public void start(Stage primaryStage) throws InterruptedException {<br>
      Image image1 = new Image(<a href="https://picsum.photos/512/512" style="color: blue; text-decoration: underline;">"https://picsum.photos/512/512"</a>);<br>
      Image image2 = new Image(<a href="https://picsum.photos/512/512" style="color: blue; text-decoration: underline;">"https://picsum.photos/512/512"</a>);<br>
<br>
      TextArea prompt = new TextArea("a flower on Mars");<br>
      Button button = new Button("Submit");<br>
      ListView<Image> listView = new ListView<>();<br>
<br>
      while(image1.isBackgroundLoading() || image2.isBackgroundLoading()) {<br>
        Thread.sleep(100);<br>
      }<br>
<br>
      listView.getItems().addAll(image1, image2);<br>
      listView.setCellFactory(lv -> {<br>
        final ImageView imageView = new ImageView();<br>
<br>
        return new ListCell<>() {<br>
          protected void updateItem(Image image, boolean empty) {<br>
            if(empty) {<br>
              setGraphic(null);<br>
            }<br>
            else {<br>
              imageView.setImage(image);<br>
              setGraphic(imageView);<br>
            }<br>
          }<br>
        };<br>
      });<br>
<br>
      HBox hbox = new HBox() {{<br>
        getChildren().addAll(<br>
          new VBox() {{<br>
            getChildren().addAll(prompt, button);<br>
          }},<br>
          listView<br>
        );<br>
      }};<br>
<br>
      HBox.setHgrow(listView, Priority.ALWAYS);<br>
<br>
      Scene scene = new Scene(hbox);<br>
<br>
      primaryStage.setScene(scene);<br>
      primaryStage.show();<br>
    }<br>
  }<br>
}<br>
<br>
<br>
<br>
<br>
<br>
--John<o:p></o:p></p>
<div>
<div style="margin: 0in; font-size: 10pt; font-family: Calibri, sans-serif;"><span style="font-size: 11pt;">On 12/07/2023 01:17, Andy Goryachev wrote:<o:p></o:p></span></div>
</div>
<blockquote style="margin-top: 5pt; margin-bottom: 5pt;">
<div style="margin: 0in; font-size: 10pt; font-family: Calibri, sans-serif;"><span style="font-size: 11pt; font-family: "Iosevka Fixed SS16 ";">I'll need to replicate this scenario to be able to say anything definitive.</span><o:p></o:p></div>
<div style="margin: 0in; font-size: 10pt; font-family: Calibri, sans-serif;"><span style="font-size: 11pt; font-family: "Iosevka Fixed SS16 ";"> </span><o:p></o:p></div>
<div style="margin: 0in; font-size: 10pt; font-family: Calibri, sans-serif;"><span style="font-size: 11pt; font-family: "Iosevka Fixed SS16 ";">Just by looking at the cell factory code though, I suspect there might be some async processing around</span><o:p></o:p></div>
<div style="margin: 0in; font-size: 10pt; font-family: Calibri, sans-serif;"><span style="font-size: 11pt; font-family: "Iosevka Fixed SS16 ";"> </span><o:p></o:p></div>
<div style="margin: 0in; font-size: 10pt; font-family: Calibri, sans-serif;"><span style="font-size: 11pt;">new ImageView(new Image(new<span class="Apple-converted-space"> </span><br>
> ByteArrayInputStream(imageHandle.getImageData()))));</span><span style="font-size: 11pt; font-family: "Iosevka Fixed SS16 ";"></span><o:p></o:p></div>
<div style="margin: 0in; font-size: 10pt; font-family: Calibri, sans-serif;"><span style="font-size: 11pt; font-family: "Iosevka Fixed SS16 ";"> </span><o:p></o:p></div>
<div style="margin: 0in; font-size: 10pt; font-family: Calibri, sans-serif;"><span style="font-size: 11pt; font-family: "Iosevka Fixed SS16 ";">which might cause the issue.</span><o:p></o:p></div>
<div style="margin: 0in; font-size: 10pt; font-family: Calibri, sans-serif;"><span style="font-size: 11pt; font-family: "Iosevka Fixed SS16 ";"> </span><o:p></o:p></div>
<div style="margin: 0in; font-size: 10pt; font-family: Calibri, sans-serif;"><span style="font-size: 11pt; font-family: "Iosevka Fixed SS16 ";">Could you try pre-loading images?</span><o:p></o:p></div>
<div style="margin: 0in; font-size: 10pt; font-family: Calibri, sans-serif;"><span style="font-size: 11pt; font-family: "Iosevka Fixed SS16 ";"> </span><o:p></o:p></div>
<div style="margin: 0in; font-size: 10pt; font-family: Calibri, sans-serif;"><span style="font-size: 11pt; font-family: "Iosevka Fixed SS16 ";">-andy</span><o:p></o:p></div>
<div style="margin: 0in; font-size: 10pt; font-family: Calibri, sans-serif;"><span style="font-size: 11pt; font-family: "Iosevka Fixed SS16 ";"> </span><o:p></o:p></div>
<div style="margin: 0in; font-size: 10pt; font-family: Calibri, sans-serif;"><span style="font-size: 11pt; font-family: "Iosevka Fixed SS16 ";"> </span><o:p></o:p></div>
<div style="margin: 0in; font-size: 10pt; font-family: Calibri, sans-serif;"><span style="font-size: 11pt; font-family: "Iosevka Fixed SS16 ";"> </span><o:p></o:p></div>
<div id="mail-editor-reference-message-container">
<div>
<div style="border-style: solid none none; border-top-width: 1pt; border-top-color: rgb(181, 196, 223); padding: 3pt 0in 0in;">
<p class="MsoNormal" style="margin: 0in 0in 12pt; font-size: 10pt; font-family: Calibri, sans-serif;">
<b><span style="font-size: 12pt;">From:<span class="Apple-converted-space"> </span></span></b><span style="font-size: 12pt;">openjfx-dev<span class="Apple-converted-space"> </span><a href="mailto:openjfx-dev-retn@openjdk.org" style="color: blue; text-decoration: underline;"><openjfx-dev-retn@openjdk.org></a><span class="Apple-converted-space"> </span>on
 behalf of Kevin Rushforth<span class="Apple-converted-space"> </span><a href="mailto:kevin.rushforth@oracle.com" style="color: blue; text-decoration: underline;"><kevin.rushforth@oracle.com></a><br>
<b>Date:<span class="Apple-converted-space"> </span></b>Tuesday, July 11, 2023 at 15:58<br>
<b>To:<span class="Apple-converted-space"> </span></b><a href="mailto:openjfx-dev@openjdk.org" style="color: blue; text-decoration: underline;">openjfx-dev@openjdk.org</a><span class="Apple-converted-space"> </span><a href="mailto:openjfx-dev@openjdk.org" style="color: blue; text-decoration: underline;"><openjfx-dev@openjdk.org></a><br>
<b>Subject:<span class="Apple-converted-space"> </span></b>Re: ListView with ImageViews for cells very bugged?</span><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin: 0in 0in 12pt; font-size: 10pt; font-family: Calibri, sans-serif;">
<span style="font-size: 11pt;">What you have should work, but will create redundant images and<span class="Apple-converted-space"> </span><br>
ImageView ojbects. The recommendation is to create the nodes (ImageView<span class="Apple-converted-space"> </span><br>
in this case) in the constructor of the cell factory and call setGraphic<span class="Apple-converted-space"> </span><br>
with either null or that factory's node.<br>
<br>
Having said that, I doubt that this is related to the visual problems<span class="Apple-converted-space"> </span><br>
you are seeing. Maybe Ajit or Andy have some ideas.<br>
<br>
-- Kevin<br>
<br>
<br>
On 7/11/2023 3:50 PM, John Hendrikx wrote:<br>
> I tend to avoid ListView, because for some reason it seems to just<span class="Apple-converted-space"> </span><br>
> never do what I want unless used for its mundane rows of text use<span class="Apple-converted-space"> </span><br>
> case. I so far always just implemented my own skin for ListView that<span class="Apple-converted-space"> </span><br>
> deals with displays that have many images that need to scroll<span class="Apple-converted-space"> </span><br>
> smoothly, but...<br>
><br>
> Recently, I've again attempted to use ListView, this time for showing<span class="Apple-converted-space"> </span><br>
> (so far) fixed size ImageViews with images exactly 512x512 pixels in<span class="Apple-converted-space"> </span><br>
> size:<br>
><br>
> The cell factory looks like this, which I think is a correct<span class="Apple-converted-space"> </span><br>
> implementation:<br>
><br>
>       listView.setCellFactory(lv -> {<br>
>         return new ListCell<>() {<br>
>           protected void updateItem(ImageHandle imageHandle, boolean<span class="Apple-converted-space"> </span><br>
> empty) {<br>
>             if(empty) {<br>
>               setGraphic(null);<br>
>             }<br>
>             else {<br>
>               try {<br>
>                 setGraphic(new ImageView(new Image(new<span class="Apple-converted-space"> </span><br>
> ByteArrayInputStream(imageHandle.getImageData()))));<br>
>               }<br>
>               catch(IOException e) {<br>
>                 e.printStackTrace();<br>
>               }<br>
>             }<br>
>           }<br>
>         };<br>
>       });<br>
><br>
> Now, this is with JavaFX 21-ea-24 (but also happens on 19).  I spotted<span class="Apple-converted-space"> </span><br>
> the following IMHO bugs:<br>
><br>
> 1) When the ImageView is so large that a single row is only partially<span class="Apple-converted-space"> </span><br>
> visible, the scrollbar is incorrect (it shows a full bar, even if half<span class="Apple-converted-space"> </span><br>
> of a row is displayed).<br>
><br>
> 2) The vertical scrollbar doesn't respond to a click in the non-thumb<span class="Apple-converted-space"> </span><br>
> area at all (you'd expect to make it scroll a page up or down that way)<br>
><br>
> 3) When jerkily resizing the window, I can sometimes have a vertical +<span class="Apple-converted-space"> </span><br>
> horizontal scrollbar when there's a full row visible + anywhere from 0<span class="Apple-converted-space"> </span><br>
> to 10 extra empty pixels (probably the potential height of a<span class="Apple-converted-space"> </span><br>
> horizontal scrollbar) with the vertical scroll bar still visible.  The<span class="Apple-converted-space"> </span><br>
> algorithm to hide the scrollbar apparently is not deterministic and<span class="Apple-converted-space"> </span><br>
> depends on mouse movement speed.<br>
><br>
> 4) When a row is less than half visible, scrolling the window down to<span class="Apple-converted-space"> </span><br>
> another ImageView will jump the view and hide the first cell that<span class="Apple-converted-space"> </span><br>
> should still be visible for the bottom 0-49% of its height.<br>
><br>
> 5) It's possible to get the vertical scroll bar in such a state that<span class="Apple-converted-space"> </span><br>
> it doesn't respond to the mouse any more at all, even by dragging the<span class="Apple-converted-space"> </span><br>
> thumb.  Some keyboard action and mouse scrolling sometimes restores it<span class="Apple-converted-space"> </span><br>
> to relatively normal functioning.<br>
><br>
> 6) Mouse wheel scrolling acts weird.  With one large cell visible and<span class="Apple-converted-space"> </span><br>
> two rows available, scrolling only **down** on the mouse wheel will<span class="Apple-converted-space"> </span><br>
> scroll down, then jump back up, and scroll down again... it's<span class="Apple-converted-space"> </span><br>
> impossible to scroll all the way down to get to a point where it stops<span class="Apple-converted-space"> </span><br>
> scrolling as it keeps jumping back.<br>
><br>
> This is with ImageView's.  I suppose they're known to have problems...<span class="Apple-converted-space"> </span><br>
> but then I switched to a Region, which contain an ImageView with<span class="Apple-converted-space"> </span><br>
> proper min/pref/max implementations.  This improved the situation<span class="Apple-converted-space"> </span><br>
> somewhat.  The scrollbar was much more reliable, but I still saw<span class="Apple-converted-space"> </span><br>
> almost all of the above issues, but somewhat more reliable than<span class="Apple-converted-space"> </span><br>
> before.  Still rows would disappear when (for the most part)<span class="Apple-converted-space"> </span><br>
> invisible, those and the jumps of the view are just totally unacceptable.<br>
><br>
> I'm not quite sure what to make of this, it seems the control is not<span class="Apple-converted-space"> </span><br>
> meant for arbitrary graphics.<br>
><br>
> --John<br>
><br>
><br>
><br>
> package org.int4.sdui.ui;<br>
><br>
> import hs.mediasystem.util.image.ImageHandle;<br>
> import hs.mediasystem.util.javafx.control.Containers;<br>
><br>
> import java.io.ByteArrayInputStream;<br>
> import java.io.IOException;<br>
> import java.util.Base64;<br>
> import java.util.List;<br>
><br>
> import javafx.application.Application;<br>
> import javafx.scene.Scene;<br>
> import javafx.scene.control.Button;<br>
> import javafx.scene.control.ListCell;<br>
> import javafx.scene.control.ListView;<br>
> import javafx.scene.control.TextArea;<br>
> import javafx.scene.image.Image;<br>
> import javafx.scene.image.ImageView;<br>
> import javafx.scene.layout.HBox;<br>
> import javafx.scene.layout.Priority;<br>
> import javafx.stage.Stage;<br>
><br>
> import kong.unirest.core.Unirest;<br>
><br>
> public class Main {<br>
><br>
>   public static void main(String[] args) {<br>
>     Application.launch(UI.class, args);<br>
>   }<br>
><br>
>   public static class UI extends Application {<br>
><br>
>     @Override<br>
>     public void start(Stage primaryStage) {<br>
>       TextArea prompt = new TextArea("a flower on Mars");<br>
>       Button button = new Button("Submit");<br>
>       ListView<ImageHandle> listView = new ListView<>();<br>
><br>
>       listView.setCellFactory(lv -> {<br>
>         return new ListCell<>() {<br>
>           protected void updateItem(ImageHandle imageHandle, boolean<span class="Apple-converted-space"> </span><br>
> empty) {<br>
>             if(empty) {<br>
>               setGraphic(null);<br>
>             }<br>
>             else {<br>
>               try {<br>
>                 setGraphic(new ImageView(new Image(new<span class="Apple-converted-space"> </span><br>
> ByteArrayInputStream(imageHandle.getImageData()))));<br>
>               }<br>
>               catch(IOException e) {<br>
>                 e.printStackTrace();<br>
>               }<br>
>             }<br>
>           }<br>
>         };<br>
>       });<br>
><br>
>       button.setOnAction(e -> {<br>
>         Txt2ImgResponse response = textToImage(prompt.getText());<br>
><br>
>         for(String image : response.images) {<br>
>           listView.getItems().add(new<span class="Apple-converted-space"> </span><br>
> InMemoryImageHandle(Base64.getDecoder().decode(image)));<br>
>         }<br>
>       });<br>
><br>
>       HBox hbox = Containers.hbox(Containers.vbox(prompt, button),<span class="Apple-converted-space"> </span><br>
> listView);<br>
><br>
>       HBox.setHgrow(listView, Priority.ALWAYS);<br>
><br>
>       Scene scene = new Scene(hbox);<br>
><br>
>       primaryStage.setScene(scene);<br>
>       primaryStage.show();<br>
>     }<br>
><br>
>     private Txt2ImgResponse textToImage(String prompt) {<br>
>       return Unirest.post("<a href="http://127.0.0.1:7860/sdapi/v1/txt2img" style="color: blue; text-decoration: underline;">http://127.0.0.1:7860/sdapi/v1/txt2img</a>")<br>
>         .body(new Txt2Img(prompt, 5))<br>
>         .contentType("application/json")<br>
>         .asObject(Txt2ImgResponse.class)<br>
>         .getBody();<br>
>     }<br>
>   }<br>
><br>
>   static class InMemoryImageHandle implements ImageHandle {<br>
>     private final byte[] data;<br>
><br>
>     public InMemoryImageHandle(byte[] data) {<br>
>       this.data = data;<br>
>     }<br>
><br>
>     @Override<br>
>     public byte[] getImageData() {<br>
>       return data;<br>
>     }<br>
><br>
>     @Override<br>
>     public String getKey() {<br>
>       return null;<br>
>     }<br>
><br>
>     @Override<br>
>     public boolean isFastSource() {<br>
>       return true;<br>
>     }<br>
>   }<br>
><br>
>   record Txt2Img(String prompt, int steps) {}<br>
>   record Txt2ImgResponse(List<String> images) {}<br>
> }<br>
><br>
><br>
></span></p>
</div>
</div>
</div>
</blockquote>
</div>
</div>
</div>
</div>
</blockquote>
</div>
<br>
</div>
</body>
</html>