Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package aprendiendointerfaces;
- import javax.swing.*;
- import java.awt.*;
- import java.awt.event.ActionEvent;
- import java.awt.event.ActionListener;
- public class Gui01 extends JFrame{
- private JLabel lbl1, lbl2;
- private JTextField txt1,txt2;
- private JButton btn;
- public Gui01(){
- lbl1=new JLabel("Original");
- lbl2=new JLabel("Copia");
- btn=new JButton(">");
- txt1=new JTextField(15);
- txt2=new JTextField(15);
- btn.addActionListener(new OyenteCopia());
- add(lbl1);
- add(txt1);
- add(btn);
- add(lbl2);
- add(txt2);
- setLayout(new FlowLayout(FlowLayout.CENTER,5,5));
- setVisible(true);
- setSize(400,150);
- setDefaultCloseOperation(EXIT_ON_CLOSE);
- }
- public static void main(String[] args) {
- Gui01 intf=new Gui01();
- }
- class OyenteCopia implements ActionListener{
- @Override
- public void actionPerformed(ActionEvent e) {
- txt2.setText(txt1.getText());
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment