Skip to content

jwharm/java-gi-examples

Repository files navigation

Examples for Java-GI

This repository contains small example applications made with Java-GI. Each example can be separately built and run with gradle run:

Hello World

A typical "Hello World" example that displays a Gtk window with a button. When you click the button, the application quits.

Hello World - template based

This is a bit more complete "Hello World" example that is based on the default application that GNOME Builder generates for new Vala projects. It uses Gtk composite template classes to define the user interface in XML files. It also includes a Flatpak manifest and instructions to install and run the example as a Flatpak application.

Calculator

A basic calculator that uses Gtk and LibAdwaita. There's a header bar, and a grid-based layout for the buttons. The app reacts to key presses as expected.

ColumnView Datagrid

An example GtkColumnView displaying a long grid of items.

List integration

This example demonstrates how you can use a Java ArrayList to implement the GListModel interface, which is central to all modern Gtk list widgets.

Notepad

A very basic Adwaita plain-text editor, that can load and save files using GIO.

Code editor

A source code editor. It is mostly the same application as the Notepad example above, but this one uses GtkSourceview as the text widget and enables line numbers and syntax highlighting.

Peg Solitaire

This game is a direct port of the Peg-Solitaire drag-and-drop example in the Gtk Demo.

WebkitGtk Web browser

This example creates a very basic web browser using WebkitGtk. It was inspired by the browser example in GNOME Workbench.

WebkitGtk Javascript callback

This example is a small WebkitGtk application that runs a Java callback function from a Javascript function in the webpage.

Mediastream

The Mediastream example is ported from GtkDemo. It paints a simple image using Cairo, and then rotates the image in a GtkVideo widget. The Cairo draw commands use the Cairo Java bindings.

GStreamer sound player

This example demonstrates how to use GStreamer and is ported from the GStreamer tutorials. It creates a GStreamer pipeline that will play sound from an Ogg Vorbis file.

GStreamer screen recorder

A command-line screen recording utility that records the screen for 5 seconds into an Ogg/Theora file. It also demonstrates how to add a Tee and an AppSink to the pipeline so you can trigger custom actions on the recorded data.

Logging adapter

A small experiment to redirect the output of the GLib logging functions to the Java logging framework SLF4J.

Spacewar

The classic Spacewar game, ported from the cairo SVG Spacewar demo to Gtk4 and Kotlin, using Java-GI.

About

Examples for Java-GI

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published