D
DW
I'm having a problem with the autoscroll in a JTextArea.
My GUI simply contains:
1. A JTextArea within a JScrollPane
2. A JTextField
The JTextField has an action listener that appends the text from the
JTextField to the JTextArea. The autoscroll works fine until I hilight
some text from the JTextArea, copy it (ctrl-c) and paste it (ctrl-p)
into the JTextField. From that point on the autoscroll no longer
works.
Here's the relevent parts of my code:
jScrollPane = new javax.swing.JScrollPane();
jTextArea = new javax.swing.JTextArea();
jTextField = new javax.swing.JTextField();
jScrollPane.setViewportView(jTextArea);
jTextArea.setAutoscrolls(true);
....
jTextField.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jTextFieldActionPerformed(evt);
}
});
....
private void jTextFieldActionPerformed(java.awt.event.ActionEvent evt)
{
jTextArea.append(jTextField.getText() + "\n");
jTextField.setText("");
}
Do I need to have key listeners for CTRL-C and/or CTRL-P and manage
the copy/paste manually?
Any suggestions are appreciated.
My GUI simply contains:
1. A JTextArea within a JScrollPane
2. A JTextField
The JTextField has an action listener that appends the text from the
JTextField to the JTextArea. The autoscroll works fine until I hilight
some text from the JTextArea, copy it (ctrl-c) and paste it (ctrl-p)
into the JTextField. From that point on the autoscroll no longer
works.
Here's the relevent parts of my code:
jScrollPane = new javax.swing.JScrollPane();
jTextArea = new javax.swing.JTextArea();
jTextField = new javax.swing.JTextField();
jScrollPane.setViewportView(jTextArea);
jTextArea.setAutoscrolls(true);
....
jTextField.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jTextFieldActionPerformed(evt);
}
});
....
private void jTextFieldActionPerformed(java.awt.event.ActionEvent evt)
{
jTextArea.append(jTextField.getText() + "\n");
jTextField.setText("");
}
Do I need to have key listeners for CTRL-C and/or CTRL-P and manage
the copy/paste manually?
Any suggestions are appreciated.