I have a problem with selecting text in a text area. The following video shows 2 windows.


The window on the left is a JTextArea component. As I drag the mouse over the text, the selection is made when the pointer is at the START of the tab. The window on the right shows the same content in NotePad, but as I drag the mouse over this text, the selection is made when the pointer is over the CENTER of the tab.

How do I get the behavior of NotePad in Java? This may be specific to my computer, I have not tested on other computers. The following code is used to create the test app.

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

public class Test extends JFrame {
public Test() {
		new WindowAdapter() {
			public void windowClosing( WindowEvent event ) {
				System.exit( 0 );

	setTitle( "Test" );
	setLocation( 500, 100 );
	add( new JTextArea( "\ta\n\tb\n\tc" ) );
	setVisible( true );
	setSize( 200, 200 );
public static void main( String[] args ) {
	new Test();
I'm guessing the issue has to do with the Cursor class and how it handles mouse events, but cannot see an easy solution. Thanks in advance for any help...