helloGnome |
import org.gnome.gtk.Gtk;
import org.gnome.gtk.Window;
import org.gnome.gtk.Widget;
import org.gnome.gdk.Event;
import org.gnome.gtk.Label;
import org.gnome.gtk.HBox;
public class helloGnome
{
public static void main(String[] args) {
final Window window;
final HBox hBox;
final Label label1, label2, label3;
Gtk.init(args);
window = new Window();
window.setTitle("Hello Raspberry Pi - java-gnome exercise");
window.connect(new Window.DeleteEvent() {
public boolean onDeleteEvent(Widget source, Event event) {
Gtk.mainQuit();
return false;
}
});
label1 = new Label("Label 1");
label2 = new Label("Label 2");
label3 = new Label("Label 3");
hBox = new HBox(false, 3);
hBox.add(label1);
hBox.add(label2);
hBox.add(label3);
window.add(hBox);
window.showAll();
Gtk.main();
}
}
Compile it with the command:
$ javac -classpath /usr/share/java/gtk-4.1.jar helloGnome.java
and run it:
$ java -classpath /usr/share/java/gtk-4.1.jar:. helloGnome
No comments:
Post a Comment