Example usage for javafx.scene.control TextField getSelectedText

List of usage examples for javafx.scene.control TextField getSelectedText

Introduction

In this page you can find the example usage for javafx.scene.control TextField getSelectedText.

Prototype

public final String getSelectedText() 

Source Link

Usage

From source file:com.bekwam.mavenpomupdater.MenuBarDelegate.java

private boolean anythingSelected() {
    TextField[] tfs = new TextField[] { tfNewVersion, tfFilters, tfRootDir };
    for (TextField tf : tfs) {
        if (StringUtils.isNotEmpty(tf.getSelectedText())) {
            return true;
        }/*from  w w w.j  av  a2s .  c om*/
    }
    return false;
}

From source file:com.bekwam.mavenpomupdater.MainViewController.java

@FXML
public void toolBarMouseReleased(MouseEvent evt) {

    TextField tf = (TextField) evt.getSource();
    String selectedText = tf.getSelectedText();
    IndexRange selectedRange = tf.getSelection();

    toolBarDelegate.updateToolBarForClipboard(tf, selectedText, selectedRange);
}

From source file:com.bekwam.mavenpomupdater.ToolBarDelegate.java

public void updateToolBarForClipboard(TextField focusedTF, String selectedText, IndexRange selectedRange) {

    if (log.isDebugEnabled()) {
        log.debug("[UPDATE TBB]");
    }/* www. ja va2  s  .c  o m*/

    if (systemClipboard == null) {
        systemClipboard = Clipboard.getSystemClipboard();
    }

    if (systemClipboard.hasString()) {
        if (log.isDebugEnabled()) {
            log.debug("[UPDATE TBB] there is content in clipboard");
        }
        adjustForClipboardContents();
    } else {
        if (log.isDebugEnabled()) {
            log.debug("[UPDATE TBB] there is NO content in clipboard");
        }
        adjustForEmptyClipboard();
    }

    if (StringUtils.isNotEmpty(focusedTF.getSelectedText())) {
        if (log.isDebugEnabled()) {
            log.debug("[UPDATE TBB] there is a selection");
        }
        adjustForSelection();

    } else {
        if (log.isDebugEnabled()) {
            log.debug("[UPDATE TBB] there is a de-selection");
        }
        adjustForDeselection();
    }

    if (log.isDebugEnabled()) {
        log.debug(
                "[UPDATE TBB]  assigining tf=" + focusedTF.getId() + " as last focused; text=" + selectedText);
    }

    lastFocusedTF = focusedTF;
    lastSelectedText = selectedText;
    lastSelectedRange = selectedRange;
}