Java JTextComponent Select selectionToUpperCase(JTextComponent textPane)

Here you can find the source of selectionToUpperCase(JTextComponent textPane)

Description

selection To Upper Case

License

Apache License

Declaration

public static void selectionToUpperCase(JTextComponent textPane) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import javax.swing.text.JTextComponent;

public class Main {
    public static void selectionToUpperCase(JTextComponent textPane) {
        int start = textPane.getSelectionStart();
        int end = textPane.getSelectionEnd();

        if (Math.abs(start - end) > 0) {
            String upper = textPane.getSelectedText().toUpperCase();
            textPane.replaceSelection(upper);

            textPane.setCaretPosition(start);
            textPane.moveCaretPosition(end);
        }/*from  ww  w . j  av a2s. c o  m*/
    }
}

Related

  1. selectAll(final JTextComponent textComponent)
  2. selectAll(JTextComponent textComponent)
  3. selectAllOnFocus(JTextComponent textComponent)
  4. selectAndRequestFocus(JTextComponent editor)
  5. selectFirstArg(String strText, int initialSelectionStart, JTextComponent editor)
  6. selectLines(JTextComponent target)
  7. toggleSelectionUpperCase(JTextComponent textPane)
  8. useSelectedTextColor(Highlighter.Highlight h, JTextComponent c)