22
33import java .io .IOException ;
44
5- import gr .sqlbrowserfx .nodes .codeareas . java . JavaCodeArea ;
5+ import gr .sqlbrowserfx .nodes .ChatGptWebView ;
66import javafx .application .Application ;
77import javafx .scene .Scene ;
88import javafx .scene .control .Button ;
9- import javafx .scene .control .ScrollPane ;
109import javafx .scene .layout .VBox ;
11- import javafx .scene .web .WebView ;
1210import javafx .stage .Stage ;
1311
1412public class ChatGptWebViewTestGui extends Application {
1513
1614 @ Override
1715 public void start (Stage primaryStage ) throws IOException {
18- var webView = new WebView ();
19- var webEngine = webView .getEngine ();
20- // Force dark color scheme via CSS injection
21- String darkModeCSS = """
22- (function() {
23- const style = document.createElement('style');
24- style.textContent = `
25- :root {
26- color-scheme: dark;
27- background-color: #222222 !important;
28- color: #e0e0e0 !important;
29- }
30- html, body *:not(pre):not(pre *) {
31- background-color: #222222 !important;
32- color: #e0e0e0 !important;
33- margin: 0 !important;
34-
35- }
36- `;
37- document.documentElement.appendChild(style);
38- })();
39- """ ;
40-
41- // Load ChatGPT and then apply dark mode styling
42- webEngine .getLoadWorker ().stateProperty ().addListener ((obs , oldState , newState ) -> {
43- if (newState == javafx .concurrent .Worker .State .SUCCEEDED ) {
44- webEngine .executeScript (darkModeCSS );
45- }
46- });
47- webEngine .load ("https://chatgpt.com/" );
48-
16+ var chatGptWebView = new ChatGptWebView ();
4917 var pasteButton = new Button ("test" );
5018 pasteButton .setOnAction (event -> {
5119 String safeText = "This is a test text pasted from java"
@@ -66,10 +34,10 @@ public void start(Stage primaryStage) throws IOException {
6634 })();
6735 """ .formatted (safeText );
6836
69- webEngine .executeScript (js );
37+ chatGptWebView . getEngine () .executeScript (js );
7038 });
7139 Scene scene = new Scene (
72- new VBox (pasteButton , webView )
40+ new VBox (pasteButton , chatGptWebView )
7341 );
7442 scene .getStylesheets ().add ("/styles/flat-dark.css" );
7543 primaryStage .setScene (scene );
0 commit comments