Me ajudem a concluir essa pequeno trabalho

galera blz… :idea:

como eu faco pra eu digitar por exemplo ( “Testando” ) em um textField e clicar em um botao (“OK”), e imprimir isso em um JTextArea??

alguem poderia me dar uma dica…

obrigado. :lol: :lol:

Ola

Neste teu botao, vc inclui um java.awt.event.ActionListener, no metodo actionPerformed, que e invocado quando o botao e acionado, vc inclui um getText no seu JTextField, e um append no seu JTextArea, e pronto.

package variados;

import java.awt.Dimension;

import java.awt.Rectangle;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JTextArea;
import javax.swing.JTextField;

public class teste extends JFrame {
    private JButton jButton1 = new JButton();

    private JTextArea jTextArea1 = new JTextArea();

    private JTextField jTextField1 = new JTextField();

    public teste() {
        try {
            jbInit();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    private void jbInit() throws Exception {
        this.getContentPane().setLayout( null );
        this.setSize( new Dimension(400, 300) );
        jButton1.setText("jButton1");
        jButton1.setBounds(new Rectangle(160, 155, 120, 40));
        jButton1.addActionListener(new ActionListener() {
                    public void actionPerformed(ActionEvent e) {
                        jButton1_actionPerformed(e);
                    }
                });
        jTextArea1.setBounds(new Rectangle(210, 20, 130, 90));
        jTextField1.setBounds(new Rectangle(35, 15, 140, 35));
        this.getContentPane().add(jTextField1, null);
        this.getContentPane().add(jTextArea1, null);
        this.getContentPane().add(jButton1, null);
    }
    
    public static void main(String[] args) {
        teste app = new teste();
        app.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        app.setVisible(true);
        
            
        
    }

    private void jButton1_actionPerformed(ActionEvent e) {
        jTextArea1.setText(jTextField1.getText());
    }
}