Advertisement
hackloper775

Table java

Oct 25th, 2013
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.32 KB | None | 0 0
  1. import org.gnome.gdk.Event;
  2. import org.gnome.gtk.*;
  3.  
  4. public class JavaGtk {
  5.     public static void main(String[] args) {
  6.          // Creamos los widgets
  7.          final Window ventana;
  8.          final Table tb;
  9.          final Button boton1;
  10.          final Button boton2;
  11.          final Button boton3;
  12.          final Button boton4;
  13.          
  14.          Gtk.init(args);
  15.                  // ^ Iniciamos Gtk y le pasamos las mismas args que usa el main que inicia la clase
  16.          
  17.          ventana = new Window(); // Creamos una ventana
  18.          ventana.setTitle("Ejemplo Table");
  19.          
  20.          tb = new Table(2,2,true);
  21.          tb.setColumnSpacing(5);
  22.          tb.setRowSpacing(5);
  23.          
  24.          boton1 = new Button();
  25.          boton1.setLabel("Boton1");
  26.          tb.attach(boton1, 0, 1, 0, 1);
  27.          
  28.          boton2 = new Button();
  29.          boton2.setLabel("Boton2");
  30.          tb.attach(boton2, 1, 2, 0, 1);
  31.          
  32.          boton3 = new Button();
  33.          boton3.setLabel("Boton3");
  34.          tb.attach(boton3, 0, 1, 1, 2);
  35.          
  36.          boton4 = new Button();
  37.          boton4.setLabel("Boton4");
  38.          tb.attach(boton4, 1, 2, 1, 2);
  39.          
  40.          ventana.add(tb); // Agregamos la tabla
  41.          
  42.          ventana.showAll(); // Mostramos todo
  43.                  
  44.          ventana.connect(new Window.DeleteEvent() { // Evento para cerrar ventana
  45.             @Override
  46.             public boolean onDeleteEvent(Widget arg0, Event arg1) {
  47.                 Gtk.mainQuit();
  48.                         return false;
  49.             }
  50.         });
  51.         Gtk.main(); // Bucle de Gtk
  52.     }
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement