import javax.swing.*; import java.awt.event.*; public class TextFieldExample { public static void main(String[] args) { JFrame frame = new JFrame("Mouse Listener Example"); JTextField textField = new JTextField(20); textField.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent e) { System.out.println("Mouse clicked on text field"); } }); frame.add(textField); frame.setSize(300, 200); frame.setVisible(true); } }In this example, we create a JFrame and a JTextField with 20 columns. We then add a MouseListener to the text field using an anonymous inner class that overrides the mouseClicked() method. When the mouse is clicked on the text field, a message is printed to the console. The package library used in this example is javax.swing.