Sunteți pe pagina 1din 1

/*APP captura de nombre Applet-12/04/2019-12:36-MariannePerez*/

package PKCapNombre;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;

public class CapNombreApplet extends JApplet implements ActionListener {


Container C_Ventana;
FlowLayout FL_Esquema;
JLabel L_nombre, L_Mensaje;
JTextField TF_Nombre;
JButton B_Mostrar;
String cadena;

public void init (){


C_Ventana= getContentPane();
FL_Esquema= new FlowLayout();
C_Ventana.setLayout(FL_Esquema);
L_nombre= new JLabel ("Escriba su nombre");
L_Mensaje= new JLabel ("Cordial saludo");
TF_Nombre= new JTextField (15);
B_Mostrar= new JButton ("Mostrar nombre");
B_Mostrar.addActionListener(this);
cadena= "";
C_Ventana.add (L_nombre);
C_Ventana.add (TF_Nombre);
C_Ventana.add (B_Mostrar);
C_Ventana.add (L_Mensaje);
setSize (200,200);
setVisible (true);

}//cierre metodo init//


public void actionPerformed(ActionEvent Evento){
if(Evento.getSource()==B_Mostrar){
cadena= TF_Nombre.getText();
L_Mensaje.setText ("Cordial saludo "+cadena);

}//cierre if//

}//cierre actionPerformed//

}//Cierre clase//

S-ar putea să vă placă și