class CommentUtil {

    private static void blockComment(JTextArea scriptPanel) {
        // Recover the index of the start of the selection.
        final int startOffset = scriptPanel.getSelectionStart();
        // Comment the selection.
        final String commentedSelection = BLOCK_COMMENT_START
                + scriptPanel.getSelectedText() + BLOCK_COMMENT_END;
        scriptPanel.replaceSelection(commentedSelection);
        // Select the commented selection.
        scriptPanel.setSelectionStart(startOffset);
        scriptPanel.setSelectionEnd(startOffset + commentedSelection.length());
    }

}