// USO DEL LIENZO --- DIBUJO DE ELEMENTOS GRAFICOS import java.awt.*; import javax.swing.*; import java.awt.event.*; // Prototipo de una aplicacion de ventana // 1.- Se crea la clase que extienda a la clase Frame, JFrame o Window public class Lienzo extends JFrame { public Lienzo () { this.getContentPane().setLayout(null); // Contenedor nulo this.setTitle("TITULO"); // Titulo de la ventana this.setResizable(false); // No es redimensionable this.setLocation(100, 100); // Posicion desde la esquina superior izquierda del monitor this.setSize(new Dimension(500, 350)); // Dimensiones setBackground(Color.blue); // COLOR DEL FONDO setVisible(true); // 2.- Se muestra la ventana } public void paint(Graphics G) // SE EJECUTA AL MOMENTO DE CREARSE LA INSTANCIA DE LA CLASE { G.setColor(Color.yellow); // COLOR DE LOS TRAZOS G.drawLine(100, 100, 300, 150); } public static void main(String R[]) { new Lienzo(); } // 3.- Captura del evento "cerrar ventana" protected void processWindowEvent(WindowEvent e) { super.processWindowEvent(e); if (e.getID() == WindowEvent.WINDOW_CLOSING) { System.exit(0); } } }