title: How to get selection from JTextPane
body: <p>I want to find out which part of JTextPanel text is selected. Tried to call <code>JTextPane.getSelectionStart()</code> and <code>JTextPane.getSelectionEnd()</code>, but they always return same value that is equal to current caret position. 
  What is my problem with that? </p>
  
  <p>I would be thankful for any code exapmle that gets current selection.</p>