pablosotol

Clase Agosto

Aug 2nd, 2016
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.30 KB | None | 0 0
  1.  
  2. package aprendiendointerfaces;
  3.  
  4. import javax.swing.*;
  5. import java.awt.*;
  6. import java.awt.event.ActionEvent;
  7. import java.awt.event.ActionListener;
  8.  
  9. public class Gui01 extends JFrame{
  10.      
  11.       private JLabel lbl1, lbl2;
  12.       private JTextField txt1,txt2;
  13.       private JButton btn;
  14.        
  15.       public Gui01(){
  16.          
  17.              lbl1=new JLabel("Original");
  18.              lbl2=new JLabel("Copia");
  19.              btn=new JButton(">");
  20.              txt1=new JTextField(15);
  21.              txt2=new JTextField(15);
  22.              
  23.              btn.addActionListener(new OyenteCopia());
  24.              
  25.              add(lbl1);
  26.              add(txt1);
  27.              add(btn);
  28.              add(lbl2);
  29.              add(txt2);
  30.            
  31.              
  32.              setLayout(new FlowLayout(FlowLayout.CENTER,5,5));
  33.              setVisible(true);
  34.              setSize(400,150);
  35.              setDefaultCloseOperation(EXIT_ON_CLOSE);
  36.      
  37.              
  38.    
  39.           }
  40.      
  41.           public static void main(String[] args) {
  42.            Gui01 intf=new Gui01();
  43.      
  44.     }
  45.          
  46.     class OyenteCopia implements ActionListener{
  47.        
  48.         @Override
  49.         public void actionPerformed(ActionEvent e) {
  50.                txt2.setText(txt1.getText());
  51.         }
  52.          
  53.     }
Advertisement
Add Comment
Please, Sign In to add comment