/** * this method will update the source control after evaluating the validation condition */ protected void onEval() { Node control = getSrcControl(); if (hasErrors.get()) { control.pseudoClassStateChanged(PSEUDO_CLASS_ERROR, true); if (control instanceof Control) { Tooltip controlTooltip = ((Control) control).getTooltip(); if (controlTooltip != null && !controlTooltip.getStyleClass().contains("error-tooltip")) { tooltip = ((Control) control).getTooltip(); } errorTooltip.setText(getMessage()); ((Control) control).setTooltip(errorTooltip); } } else { if (control instanceof Control) { Tooltip controlTooltip = ((Control) control).getTooltip(); if ((controlTooltip != null && controlTooltip.getStyleClass().contains("error-tooltip")) || (controlTooltip == null && tooltip != null)) { ((Control) control).setTooltip(tooltip); } tooltip = null; } control.pseudoClassStateChanged(PSEUDO_CLASS_ERROR, false); } }
/** * set the toolTip * * @param toolTip */ public void setToolTip(String toolTip) { if (control.getTooltip() == null) control.setTooltip(new Tooltip()); control.getTooltip().setText(toolTip); }
public List<Node> createButtonList() { ArrayList<Node> result = new ArrayList<Node>(); for (final FormCreator form : childFormCreators) { Control createShowFormButton = form.createShowFormButton(); createShowFormButton.setDisable(!form.isEnabled()); createShowFormButton.setTooltip(form.getTooltip()); if (!form.isEnabled()) {/* * workaround disabled button must be wrapped in split pane to show tooltip * https://javafx-jira.kenai.com/browse/RT-28850 */ SplitPane wrapper = new SplitPane(); wrapper.getItems().add(createShowFormButton); createShowFormButton = wrapper; wrapper.setTooltip(form.getTooltip()); } result.add(createShowFormButton); } return result; }
final Button helpButton = new Button("Help"); helpButton.setOnAction(new EventHandler() { public void handle(Event arg0) { showTooltip(stage, helpButton, "test tool tip", null); } }); public static void showTooltip(Stage owner, Control control, String tooltipText, ImageView tooltipGraphic) { Point2D p = control.localToScene(0.0, 0.0); final Tooltip customTooltip = new Tooltip(); customTooltip.setText(tooltipText); control.setTooltip(customTooltip); customTooltip.setAutoHide(true); customTooltip.show(owner, p.getX() + control.getScene().getX() + control.getScene().getWindow().getX(), p.getY() + control.getScene().getY() + control.getScene().getWindow().getY()); }
tooltip = new Tooltip(); tooltip.setText(field.getHint()); control.setTooltip(tooltip);
/** * this method will update the source control after evaluating the validation condition */ protected void onEval() { Node control = getSrcControl(); if (hasErrors.get()) { control.pseudoClassStateChanged(PSEUDO_CLASS_ERROR, true); if (control instanceof Control) { Tooltip controlTooltip = ((Control) control).getTooltip(); if (controlTooltip != null && !controlTooltip.getStyleClass().contains("error-tooltip")) { tooltip = ((Control) control).getTooltip(); } errorTooltip.setText(getMessage()); ((Control) control).setTooltip(errorTooltip); } } else { if (control instanceof Control) { Tooltip controlTooltip = ((Control) control).getTooltip(); if ((controlTooltip != null && controlTooltip.getStyleClass().contains("error-tooltip")) || (controlTooltip == null && tooltip != null)) { ((Control) control).setTooltip(tooltip); } tooltip = null; } control.pseudoClassStateChanged(PSEUDO_CLASS_ERROR, false); } }