question: public Shape paintLayer ( Graphics g , int offs0 , int offs1 , Shape bounds , JTextComponent c , View view ) { Graphics2D g2d = ( Graphics2D ) g ; Composite originalComposite = null ; if ( getAlpha ( ) < 1.0f ) { originalComposite = g2d . getComposite ( ) ; g2d . setComposite ( getAlphaComposite ( ) ) ; } Paint paint = getPaint ( ) ; if ( paint == null ) g2d . setColor ( c . getSelectionColor ( ) ) ; else g2d . setPaint ( paint ) ; if ( offs0 == view . getStartOffset ( ) && offs1 == view . getEndOffset ( ) ) { Rectangle alloc ; if ( bounds instanceof Rectangle ) alloc = ( Rectangle ) bounds ; else alloc = bounds . getBounds ( ) ; g2d . fillRect ( alloc . x , alloc . y , alloc . width , alloc . height ) ; if ( getAlpha ( ) < 1.0f ) g2d . setComposite ( originalComposite ) ; return alloc ; } else { try { Shape shape = view . modelToView ( offs0 , Position . Bias . Forward , offs1 , Position . Bias . Backward , bounds ) ; Rectangle r = ( shape instanceof Rectangle ) ? ( Rectangle ) shape : shape . getBounds ( ) ; if ( roundedEdges ) { g2d . fillRoundRect ( r . x , r . y , r . width , r . height , ARCWIDTH , ARCHEIGHT ) ; } else { g2d . fillRect ( r . x , r . y , r . width , r . height ) ; } if ( getAlpha ( ) < 1.0f ) g2d . setComposite ( originalComposite ) ; return r ; } catch ( BadLocationException ble ) { ble . printStackTrace ( ) ; } finally { if ( getAlpha ( ) < 1.0f ) g2d . setComposite ( originalComposite ) ; } } return null ; }
target:  Paints a portion of a highlight.