Ventana4
package TercerSemestre;
/**Dylan Cueto Garduño 3°"D" 08-09-14 **/
@SuppressWarnings("serial")
public class _Ventana4_ extends javax.swing.JFrame {
//VARIABLE PARA DEFINIR UNA ETIQUETA
javax.swing.JLabel etiqueta;
//VARIABLE PARA UNA CAJA DE TEXTO
javax.swing.JTextField campoTexto;
//VARIABLE PARA UN BOTON
javax.swing.JButton boton;
public _Ventana4_() {
setSize(500, 400);
setTitle("Mi cuarta ventana");
//DEFINICION DE LA ETIQUETA
etiqueta = new javax.swing.JLabel();
//DEFINICION DE LA CAJA DE TEXTO
campoTexto = new javax.swing.JTextField();
//DEFINICION DE UN BOTON DE ACCION
boton = new javax.swing.JButton();
//SE TERMINA LA DEFINICION DE LA ETIQUETA
getContentPane().setLayout(null);
etiqueta.setText("Hola, programador.");
getContentPane().add(etiqueta);
//SE TERMINA LA DEFINICION DE LA CAJA DE TEXTO
getContentPane().add(campoTexto);
//SE TERMINA LA DEFINICION DEL BOTON
boton.setText("Aceptar");
getContentPane().add(boton);
//SE LLAMAN LOS ELEMENTOS Y SE LES PROPORCIONAN LA POSICION
//Y EL ANCHO(COLUMNAS) Y LARGO(FILAS)
campoTexto.setBounds(200, 50, 200, 40);
etiqueta.setBounds(50, 50, 150, 40);
boton.setBounds(120, 120, 150, 40);
setDefaultCloseOperation(EXIT_ON_CLOSE);
//DAR FUNCIONALIDAD AL BOTON
boton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent e) {
//INICIO DEL BLOQU PARA CONTROLAR LAS ACCIONES
campoTexto.setText("Dylan");
etiqueta.setText("Buen día"); } } );
addWindowListener(new java.awt.event.WindowAdapter() {
@SuppressWarnings("unused")
public void windowClosing(java.awt.event.WindowAdapter evt) {
System.exit(0);
}
} );
}
public static void main(String[] args) {
new _Ventana4_().setVisible(true);
}
}