SHARE
TWEET

Untitled

a guest Jun 17th, 2015 10 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import java.awt.FlowLayout;
  2. import java.awt.event.ActionEvent;
  3. import java.awt.event.ActionListener;
  4. import javax.swing.JButton;
  5. import javax.swing.JFrame;
  6. import static javax.swing.JFrame.EXIT_ON_CLOSE;
  7. import javax.swing.JTextField;
  8.  
  9. public class Listener {
  10.  
  11.     static JTextField pole1;
  12.     static JTextField pole2;
  13.  
  14.     public static void main(String[] args) {
  15.         JFrame okno = new JFrame();
  16.         okno.setDefaultCloseOperation(EXIT_ON_CLOSE);
  17.         okno.setLayout(new FlowLayout());
  18.         pole1 = new JTextField(12);
  19.         pole2 = new JTextField(12);
  20.         JButton ok = new JButton("ok");
  21.         okno.add(pole1);
  22.         okno.add(pole2);
  23.         okno.add(ok);
  24.  
  25.         ok.addActionListener(new okAL());
  26.  
  27.         String text1 = ok.getText();
  28.  
  29.         okno.setVisible(true);
  30.         okno.pack();
  31.  
  32.     }
  33.  
  34.     public static class okAL implements ActionListener {
  35.  
  36.         @Override
  37.         public void actionPerformed(ActionEvent event) {
  38.             String text1 = pole1.getText();
  39.             pole2.setText(text1);
  40.  
  41.         }
  42.     }
  43.  
  44. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top