Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import org.gnome.gdk.Event;
- import org.gnome.gtk.*;
- public class JavaGtk {
- public static void main(String[] args) {
- // Creamos los widgets
- final Window ventana;
- final Table tb;
- final Button boton1;
- final Button boton2;
- final Button boton3;
- final Button boton4;
- Gtk.init(args);
- // ^ Iniciamos Gtk y le pasamos las mismas args que usa el main que inicia la clase
- ventana = new Window(); // Creamos una ventana
- ventana.setTitle("Ejemplo Table");
- tb = new Table(2,2,true);
- tb.setColumnSpacing(5);
- tb.setRowSpacing(5);
- boton1 = new Button();
- boton1.setLabel("Boton1");
- tb.attach(boton1, 0, 1, 0, 1);
- boton2 = new Button();
- boton2.setLabel("Boton2");
- tb.attach(boton2, 1, 2, 0, 1);
- boton3 = new Button();
- boton3.setLabel("Boton3");
- tb.attach(boton3, 0, 1, 1, 2);
- boton4 = new Button();
- boton4.setLabel("Boton4");
- tb.attach(boton4, 1, 2, 1, 2);
- ventana.add(tb); // Agregamos la tabla
- ventana.showAll(); // Mostramos todo
- ventana.connect(new Window.DeleteEvent() { // Evento para cerrar ventana
- @Override
- public boolean onDeleteEvent(Widget arg0, Event arg1) {
- Gtk.mainQuit();
- return false;
- }
- });
- Gtk.main(); // Bucle de Gtk
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement