Categoria: snippet

  • Swing: how to discover the current character position on a JEditPane

    Did you ever had the need to know your current character position on a JEditorPane? Well, I had to and, for my surprise, it wasn’s so simple as I thought. In a first moment, I thought: “hmm… probably there’s some method in this class like getCurrentCharacterLine() or getCurrentCharacterColumn() that I can use”. Well, that’s not…

  • JEditPane: como descobrir a posição do cursor?

    Recentemente me deparei com o seguinte problema: ao desenvolver uma DSL usando Groovy, me vi na necessidade de verificar em qual linha do meu código erros eram encontrados ao serem executados pelo interpretador. O script em questão era digitado em um componente do tipo JEditorPane. Em um primeiro pensei: “moleza!”, no entanto, não há um…