Por favor, não leve a mal, mas como seu código tava meio bagunçado e com alguns erros, fiz um exemplinho meio tosco mas que dá pra vc ver a utilização do JTextArea. Copie o código e execute, ok?
package customJTextField;
import java.awt.Color;
import java.awt.Container;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.border.LineBorder;
public class TextAreaDemo2 extends JFrame {
private JTextArea
txaCopy,
txaPaste
;
private JButton
btnCopy,
btnClearCopy,
btnClearPaste,
btnFindCopy,
btnFindPaste,
btnExit
;
private final int
TXA_W = 300,
TXA_H = 300,
BTN_W = 115,
BTN_H = 25
;
public TextAreaDemo2() {
instanciateComponents();
configGUI();
}
private void instanciateComponents() {
txaCopy = new JTextArea(
"Sonho que se sonha só\n" +
"É só um sonho que se sonha só\n" +
"Mas sonho que se sonha junto é realidade"
);
txaCopy.setWrapStyleWord(true);
txaCopy.setBounds(5, 5, TXA_W, TXA_H);
btnClearCopy = new JButton("Limpar");
btnClearCopy.setBounds(
txaCopy.getX(),
txaCopy.getY() + txaCopy.getHeight(),
txaCopy.getWidth() / 2,
BTN_H
);
btnClearCopy.addActionListener(
new ActionListener() {
public void actionPerformed(ActionEvent e) {
txaCopy.setText("");
}
}
);
btnFindCopy = new JButton("Procurar texto");
btnFindCopy.setBounds(
btnClearCopy.getX() + btnClearCopy.getWidth(),
btnClearCopy.getY(),
btnClearCopy.getWidth(),
BTN_H
);
btnFindCopy.addActionListener(new FindButtonHandler(txaCopy));
btnCopy = new JButton(">> Copiar >>");
btnCopy.setBounds(
txaCopy.getX() + TXA_W + 5,
(TXA_H - BTN_H) / 2,
BTN_W,
BTN_H
);
btnCopy.addActionListener(new CopyButtonHandler());
txaPaste = new JTextArea();
txaPaste.setWrapStyleWord(true);
txaPaste.setEditable(false);
txaPaste.setBackground(new Color(210, 210, 210));
txaPaste.setBounds(
btnCopy.getX() + BTN_W + 5,
txaCopy.getY(),
TXA_W,
TXA_H
);
btnClearPaste = new JButton("Limpar");
btnClearPaste.setBounds(
txaPaste.getX(),
txaPaste.getY() + txaPaste.getHeight(),
txaPaste.getWidth() / 2,
BTN_H
);
btnClearPaste.addActionListener(
new ActionListener() {
public void actionPerformed(ActionEvent e) {
txaPaste.setText("");
}
}
);
btnFindPaste = new JButton("Procurar texto");
btnFindPaste.setBounds(
btnClearPaste.getX() + btnClearPaste.getWidth(),
btnClearPaste.getY(),
btnClearPaste.getWidth(),
BTN_H
);
btnFindPaste.addActionListener(new FindButtonHandler(txaPaste));
btnExit = new JButton("Sair");
btnExit.setBounds(
btnCopy.getX(),
btnClearCopy.getY() + BTN_H + 10,
BTN_W,
BTN_H
);
btnExit.addActionListener(
new ActionListener() {
public void actionPerformed(ActionEvent e) {
System.exit(0);
}
}
);
}
private void configGUI() {
JScrollPane
scrlCopy = new JScrollPane(txaCopy),
scrlPaste = new JScrollPane(txaPaste);
;
scrlCopy.setBounds(txaCopy.getBounds());
scrlCopy.setBorder(
BorderFactory.createTitledBorder(new LineBorder(Color.blue), "Texto fonte")
);
scrlPaste.setBounds(txaPaste.getBounds());
scrlPaste.setBorder(
BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "Texto Copiado")
);
Container c = getContentPane();
c.setLayout(null);
c.add(scrlCopy);
c.add(scrlPaste);
c.add(btnCopy);
c.add(btnClearCopy);
c.add(btnClearPaste);
c.add(btnFindCopy);
c.add(btnFindPaste);
c.add(btnExit);
setTitle("Testando JTextArea");
setSize(
txaPaste.getX() + txaPaste.getWidth() + 12,
btnExit.getY() + btnExit.getHeight() + 40
);
setLocation((800 - getWidth())/2, (600 - getHeight())/2);
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
}
public static void main(String[] args) {
TextAreaDemo2 app = new TextAreaDemo2();
app.show();
}
private class FindButtonHandler implements ActionListener {
private JTextArea txa;
public FindButtonHandler(JTextArea txa) {
this.txa = txa;
}
/* ********************************************
* Este método é o que realmente te interessa *
* ********************************************/
public void actionPerformed(ActionEvent e) {
String find = null;
try {
find = JOptionPane.showInputDialog(
txa.getParent(),
"Insira o texto procurado"
).toLowerCase();
} catch (Exception exp) {
return;
}
int findPos = txa.getText().toLowerCase().indexOf(find);
txa.grabFocus();
txa.select(findPos, findPos + find.length());
}
}
private class CopyButtonHandler implements ActionListener {
public void actionPerformed(ActionEvent e) {
txaPaste.insert(
txaCopy.getSelectedText(),
txaPaste.getCaretPosition()
);
}
}
}
Qualquer dúvida, estamos aí!