Commit a4bc875f authored by Alberto Fanjul's avatar Alberto Fanjul
Browse files

maven project with Builder config

parents
[default]
name=Default
runtime=host
toolchain=default
config-opts=
run-opts=
prefix=/home/alberto/.var/app/org.gnome.Builder/cache/gnome-builder/install/pressme/host
app-id=
postbuild=
prebuild=
default=true
run-opts=-Dexec.mainClass=org.gnome.examples.App
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.gnome.examples</groupId>
<artifactId>PressMe</artifactId>
<packaging>jar</packaging>
<version>1.0</version>
<name>PressMe</name>
<url>http://maven.apache.org</url>
<repositories>
<repository>
<id>turenar-mvnrepo</id>
<name>Elnetw's Maven Repository</name>
<url>http://einzbern.turenar.mydns.jp/maven/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>net.sourceforge.java-gnome</groupId>
<artifactId>java-gnome</artifactId>
<version>[4.1,]</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
package org.gnome.examples;
/**
* Hello world!
*
*/
public class App
{
public static void main( String[] args )
{
System.out.println( "Hello World!" );
}
}
/* Hello.java
*
* Copyright 2018 Unknown <unknown@domain.org>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* SPDX-License-Identifier: GPL-3.0-or-later
*/
package org.gnome.examples.button;
public class Hello
{
}
\ No newline at end of file
/*
* java-gnome, a UI library for writing GTK and GNOME programs from Java!
*
* Copyright © 2006-2010 Operational Dynamics Consulting, Pty Ltd
*
* The code in this file, and the program it is a part of, is made available
* to you by its authors as open source software: you can redistribute it
* and/or modify it under the terms of the GNU General Public License version
* 2 ("GPL") as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GPL for more details.
*
* You should have received a copy of the GPL along with this program. If not,
* see http://www.gnu.org/licenses/. The authors of this program may be
* contacted through http://java-gnome.sourceforge.net/.
*/
package org.gnome.examples.button;
import java.io.FileNotFoundException;
import org.gnome.gdk.Event;
import org.gnome.gdk.Pixbuf;
import org.gnome.gtk.Button;
import org.gnome.gtk.Gtk;
import org.gnome.gtk.Label;
import org.gnome.gtk.VBox;
import org.gnome.gtk.Widget;
import org.gnome.gtk.Window;
/**
* A simple Window with a Label and a Button in it. Demonstrates the basics of
* initializing GTK, packing Widgets into Containers, and hooking up signals.
*
* This example has been around, in one form or another, since the very
* beginnings of java-gnome. If you're just starting out with GTK and GNOME
* don't worry; we started here too.
*
* @author Andrew Cowie
* @since 4.0.0
*/
public class PressMe
{
public static void main(String[] args) throws FileNotFoundException {
final Window w;
final VBox x;
final Label l;
final Button b;
final Pixbuf logo;
/*
* Initialize GTK. You MUST call this to load the library before
* trying to use any other elements provided by java-gnome.
*/
Gtk.init(args);
/*
* Create a top level Window. It's the Container around which the
* window manager draws decorations such as a title bar, minimize and
* close buttons, resize edges, etc.
*/
w = new Window();
/*
* Since a Window is a Bin, it can only have one child Widget. That's
* probably not very useful in most cases. To take that one slot and
* turn it into many, we use a VBox, a Container that will stack its
* children vertically.
*/
x = new VBox(false, 3);
/*
* Create a Label with some text describing the Button that will
* follow, then add it to the VBox.
*/
l = new Label("Go ahead:\nMake my day");
x.add(l);
/*
* Create our Button, with a nice explicit bit of text labelling it
* and what you're to do.
*/
b = new Button("Press me!");
x.add(b);
/*
* Now the magic part. Just sitting there, the Button won't do
* anything. You need to hook up a "signal handler" to deal with the
* 'clicked' signal. This is how we do it in java-gnome.
*
* Button.Clicked is a Java interface. You create an instance of it to
* do what you want when the callback happens, and then pass it to the
* Button's connect() method.
*
* The onClicked() method is what is required by the Button.Clicked
* interface. Most IDEs will prompt you asking if you want to "Add
* unimplemented methods?" You bet! And ta-da! You have exactly the
* signature you need to implement a 'clicked' signal handler.
*
* Since we declared b as final we can use it in the anonymous nested
* class (yet another reason that final is worth using). If the
* situation were otherwise, then the source parameter can be used to
* find out what Button was clicked.
*/
b.connect(new Button.Clicked() {
public void onClicked(Button source) {
System.out.println("I was clicked: " + b.getLabel());
}
});
/*
* Now we pack the VBox into our Window, set the Window's title, and
* invoke the command to realize everything onto the screen.
*/
w.add(x);
w.setTitle("Hello World");
w.showAll();
/*
* We would be be done except for one last detail. Closing a Window
* does not terminate the application. If that's what you want (and we
* do indeed want that here) then you need to hook up a handler to do
* something when the 'delete-event' signal is emitted.
*
* Again, the method here implements the interface.
*/
w.connect(new Window.DeleteEvent() {
public boolean onDeleteEvent(Widget source, Event event) {
Gtk.mainQuit();
return false;
}
});
/*
* Just not much of a program if it doesn't have an icon!
*/
logo = new Pixbuf("src/bindings/java-gnome_Icon.png");
w.setIcon(logo);
/*
* Now we're ready to run the main loop. The signals we've hooked up
* handlers for above won't be emitted until the user does something,
* but no events will be processed until the main loop is running;
* that's where the signals will come from. This call blocks. You have
* finished setting things up and now it's up to your signal handlers
* to carry out the program's logic in response to the user's actions;
* the essence of event-driven programming.
*/
Gtk.main();
}
}
package org.gnome.examples;
import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
/**
* Unit test for simple App.
*/
public class AppTest
extends TestCase
{
/**
* Create the test case
*
* @param testName name of the test case
*/
public AppTest( String testName )
{
super( testName );
}
/**
* @return the suite of tests being tested
*/
public static Test suite()
{
return new TestSuite( AppTest.class );
}
/**
* Rigourous Test :-)
*/
public void testApp()
{
assertTrue( true );
}
public void testAppFail()
{
assertTrue( false );
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment