@Override
	public void mouseDragged( MouseEvent e ) {
		if( (isWordSelection || isLineSelection) &&
			!e.isConsumed() && SwingUtilities.isLeftMouseButton( e ) )
		{
			// fix Swing's double/triple-click-and-drag behavior so that dragging after
			// a double/triple-click extends selection by whole words/lines
			JTextComponent c = getComponent();
			int pos = c.viewToModel( e.getPoint() );
			if( pos < 0 )
				return;

			try {
				if( pos > dragSelectionEnd )
					select( dragSelectionStart, isWordSelection ? Utilities.getWordEnd( c, pos ) : Utilities.getRowEnd( c, pos ) );
				else if( pos < dragSelectionStart )
					select( dragSelectionEnd, isWordSelection ? Utilities.getWordStart( c, pos ) : Utilities.getRowStart( c, pos ) );
				else
					select( dragSelectionStart, dragSelectionEnd );
			} catch( BadLocationException ex ) {
				UIManager.getLookAndFeel().provideErrorFeedback( c );
			}
		} else
			super.mouseDragged( e );
	}
Caret that can select all text on focus gained.
Also fixes Swing's double-click-and-drag behavior so that dragging after
a double-click extends selection by whole words.

@author Karl Tauber
flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatCaret.java