Java Code Examples for javafx.scene.Node#isFocused()

The following examples show how to use javafx.scene.Node#isFocused() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SimpleControl.java    From PreferencesFX with Apache License 2.0 6 votes vote down vote up
/**
 * Sets the error message as tooltip for the matching control.
 *
 * @param below     The control needed for positioning the tooltip.
 * @param reference The control which gets the tooltip.
 */
@Override
protected void toggleTooltip(Node reference, Control below) {
  String fieldTooltip = field.getTooltip();

  if ((reference.isFocused() || reference.isHover())
      && (!fieldTooltip.equals("") || field.getErrorMessages().size() > 0)) {
    tooltip.setText((!fieldTooltip.equals("") ? fieldTooltip + "\n" : "")
        + String.join("\n", field.getErrorMessages()));

    if (tooltip.isShowing()) {
      return;
    }

    Point2D p = below.localToScene(0.0, 0.0);

    tooltip.show(
        reference.getScene().getWindow(),
        p.getX() + reference.getScene().getX() + reference.getScene().getWindow().getX(),
        p.getY() + reference.getScene().getY() + reference.getScene().getWindow().getY()
            + below.getHeight() + 5
    );
  } else {
    tooltip.hide();
  }
}
 
Example 2
Source File: SVRemoteNodeAdapter.java    From scenic-view with GNU General Public License v3.0 5 votes vote down vote up
public SVRemoteNodeAdapter(final Node node, final boolean collapseControls, final boolean collapseContentControls, final boolean fillChildren, final SVRemoteNodeAdapter parent) {
    super(ConnectorUtils.nodeClass(node), node.getClass().getName());
    boolean mustBeExpanded = !(node instanceof Control) || !collapseControls;
    if (!mustBeExpanded && !collapseContentControls) {
        mustBeExpanded = node instanceof TabPane || node instanceof SplitPane || node instanceof ScrollPane || node instanceof Accordion || node instanceof TitledPane;
    }
    setExpanded(mustBeExpanded);
    this.id = node.getId();
    this.nodeId = ConnectorUtils.getNodeUniqueID(node);
    this.focused = node.isFocused();
    if (node.getParent() != null && parent == null) {
        this.parent = new SVRemoteNodeAdapter(node.getParent(), collapseControls, collapseContentControls, false, null);
    } else if (parent != null) {
        this.parent = parent;
    }
    /**
     * Check visibility and mouse transparency after calculating the parent
     */
    this.mouseTransparent = node.isMouseTransparent() || (this.parent != null && this.parent.isMouseTransparent());
    this.visible = node.isVisible() && (this.parent == null || this.parent.isVisible());

    /**
     * TODO This should be improved
     */
    if (fillChildren) {
        nodes = ChildrenGetter.getChildren(node)
                  .stream()
                  .map(childNode -> new SVRemoteNodeAdapter(childNode, collapseControls, collapseContentControls, true, this))
                  .collect(Collectors.toList());
    }
}