void (Graphics g, JTree tr) { final Rectangle rect = tr.getVisibleRect(); final int firstVisibleRow = tr.getClosestRowForLocation(rect.x, rect.y); final int lastVisibleRow = tr.getClosestRowForLocation(rect.x, rect.y + rect.height); for (int row = firstVisibleRow; row <= lastVisibleRow; row++) { if (tr.getSelectionModel().isRowSelected(row) && myWideSelectionCondition.value(row)) { final Rectangle bounds = tr.getRowBounds(row); g.setColor(RenderingUtil.getSelectionBackground(tree)); g.fillRect(0, bounds.y, tr.getWidth(), bounds.height); } } }