INTRODUCCIÓN A JAVA CON NETBEANS IDE 8.1: Creación de formulario "Saludar"
Nuevo Proyecto en Java:
JAVA EE: EDICIONES EMPRESARIALES (ingreso de tipo de datos restringido)
Crear un proyecto y un formulario:

Formulario resultante:
Programación para el botón "Salir":
private void btn_salirActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
System.exit(0);
}
O también,
private void btn_salirActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
dispose();
}
Descarga el código
JAVA EE: EDICIONES EMPRESARIALES (ingreso de tipo de datos restringido)
Crear un proyecto y un formulario:

Eventos: Son acciones que realizamos sobre un objeto
Programación en el evento por defecto del botón "Saludar" (al hacer doble click)
private void btn_saludarActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
//variables
String nombres, apellidos;
//obteniendo los valores de las cajas de texto
nombres = txt_nombres.getText();
apellidos = txt_apellidos.getText();
JOptionPane.showMessageDialog(rootPane, "Hola " + nombres + "\n "+apellidos, "Saludos",2);
lbl_registrado.setText("Registrado como: "+nombres+" "+apellidos);
btn_saludar.setEnabled(false);
}
Con las teclas: Control + Barra espaciadora, durante el código nos muestra las recomendaciones así como la documentación.
Programación para el botón "Salir":
private void btn_salirActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
System.exit(0);
}
O también,
private void btn_salirActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
dispose();
}
Descarga el código
Comentarios
Publicar un comentario