From d7c7b577eee17d7f41e36d9e83e25a9e99f03f02 Mon Sep 17 00:00:00 2001 From: Ninjdai Date: Wed, 20 Nov 2024 17:36:04 +0100 Subject: [PATCH] feat: java-gtk dependency --- .idea/encodings.xml | 7 +++++ pom.xml | 17 ++++++++++-- src/main/java/dev/ninjdai/Main.java | 40 +++++++++++++++++++++-------- 3 files changed, 52 insertions(+), 12 deletions(-) create mode 100644 .idea/encodings.xml diff --git a/.idea/encodings.xml b/.idea/encodings.xml new file mode 100644 index 0000000..aa00ffa --- /dev/null +++ b/.idea/encodings.xml @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/pom.xml b/pom.xml index 0b6fc4f..d8a7240 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ 4.0.0 dev.ninjdai - stalgtk + prosopagtk 1.0-SNAPSHOT @@ -13,5 +13,18 @@ 21 UTF-8 - + + + jitpack.io + https://jitpack.io + + + + + com.github.bailuk + java-gtk + v0.5.0 + + + \ No newline at end of file diff --git a/src/main/java/dev/ninjdai/Main.java b/src/main/java/dev/ninjdai/Main.java index 9df7ed7..91b776a 100644 --- a/src/main/java/dev/ninjdai/Main.java +++ b/src/main/java/dev/ninjdai/Main.java @@ -1,17 +1,37 @@ package dev.ninjdai; -//TIP To Run code, press or -// click the icon in the gutter. +import ch.bailu.gtk.gtk.Application; +import ch.bailu.gtk.gtk.ApplicationWindow; +import ch.bailu.gtk.gio.ApplicationFlags; +import ch.bailu.gtk.gtk.Button; +import ch.bailu.gtk.type.Strs; + public class Main { public static void main(String[] args) { - //TIP Press with your caret at the highlighted text - // to see how IntelliJ IDEA suggests fixing it. - System.out.printf("Hello and welcome!"); + var app = new Application("com.example.hello", + ApplicationFlags.FLAGS_NONE); - for (int i = 1; i <= 5; i++) { - //TIP Press to start debugging your code. We have set one breakpoint - // for you, but you can always add more by pressing . - System.out.println("i = " + i); - } + app.onActivate(() -> { + // Create a new window + var window = new ApplicationWindow(app); + + // Create a new button + var button = new Button(); + + // Set button label + button.setLabel("Hello, World!"); + + // When the button is clicked, close the window + button.onClicked(window::close); + + window.setChild(button); + window.show(); + }); + + // Start application main loop + var result = app.run(args.length, new Strs(args)); + + // Terminate with exit code + System.exit(result); } } \ No newline at end of file