Hello, how could you help me? I am new to the topic of events in java.
I have this class, which simply creates a form with 2 JTextArea objects.
I would like to know how to print a hello on the console by alternating the cursor position between the 2 JTextArea objects; that is to say if for example I write something in ct and then I click on ct2 that prints in console "hello"
package javaapplication1;
import javax.swing.*;
import javax.swing.JButton;
import javax.swing.JFrame;
public class JavaApplication1 extends JFrame
{
private JTextArea ct;
private JTextArea ct2;
public JavaApplication1()
{
setLayout (null);
ct = new JTextArea();
ct.setSize(75,30);
ct.setLocation(0, 0);
add(ct);
ct2 = new JTextArea();
ct2.setSize(75,30);
ct2.setLocation(100, 0);
add(ct2);
}
public static void main(String[] args)
{
JavaApplication1 v1 = new JavaApplication1();
v1.setVisible(true);
v1.setSize(200, 200);
}
}