0% found this document useful (0 votes)
26 views2 pages

Operaciones Ventanas

The document shows how to create a window in Java and add listeners to handle window events like opening, closing, activating, and deactivating. It creates a JFrame window, adds a JTextArea, sets properties like size and close operation, and adds a WindowListener class to handle the different window events.

Uploaded by

Miguel Chiara
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
26 views2 pages

Operaciones Ventanas

The document shows how to create a window in Java and add listeners to handle window events like opening, closing, activating, and deactivating. It creates a JFrame window, adds a JTextArea, sets properties like size and close operation, and adds a WindowListener class to handle the different window events.

Uploaded by

Miguel Chiara
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

import java.awt.

Button;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JTextArea;

/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
/**
*
* @author Administrador
*/
public class OperacionesVentanas {
private JFrame ventana = new JFrame();;

public OperacionesVentanas() {
ventana.setTitle("Muestra ventana");
ventana.add(new JTextArea("Esto son operaciones con ventanas"));
ventana.setSize(640, 480);
ventana.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
ventana.setVisible(true);
ventana.addWindowListener(new EscuchaVentana());
}

class EscuchaVentana implements WindowListener{


public void windowActivated(WindowEvent e){
System.out.println("Ventana activada");
}

public void windowClosed(WindowEvent e){


System.out.println("Ventana cerrada");
}

public void windowClosing(WindowEvent e){


System.out.println("Ventana cerrandose");
ventana.dispose();
}

public void windowDeactivated(WindowEvent e){


System.out.println("Ventana desactivada");
}

public void windowDeiconified(WindowEvent e){


System.out.println("Ventana desoculta");
}

public void windowIconified(WindowEvent e){


System.out.println("Ventana oculta");
}

public void windowOpened(WindowEvent e){


System.out.println("ventana abierta");
}

}
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
new OperacionesVentanas();
}
}

You might also like