Java Code Examples for javafx.scene.control.Tooltip#setFont()
The following examples show how to use
javafx.scene.control.Tooltip#setFont() .
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: World.java From charts with Apache License 2.0 | 6 votes |
public void addLocation(final Location LOCATION) { double x = (LOCATION.getLongitude() + 180) * (PREFERRED_WIDTH / 360) + MAP_OFFSET_X; double y = (PREFERRED_HEIGHT / 2) - (PREFERRED_WIDTH * (Math.log(Math.tan((Math.PI / 4) + (Math.toRadians(LOCATION.getLatitude()) / 2)))) / (2 * Math.PI)) + MAP_OFFSET_Y; Circle locationIcon = new Circle(x, y, size * 0.01); locationIcon.setFill(null == LOCATION.getColor() ? getLocationColor() : LOCATION.getColor()); StringBuilder tooltipBuilder = new StringBuilder(); if (!LOCATION.getName().isEmpty()) tooltipBuilder.append(LOCATION.getName()); if (!LOCATION.getInfo().isEmpty()) tooltipBuilder.append("\n").append(LOCATION.getInfo()); String tooltipText = tooltipBuilder.toString(); if (!tooltipText.isEmpty()) { Tooltip tooltip = new Tooltip(tooltipText); tooltip.setFont(Font.font(10)); Tooltip.install(locationIcon, tooltip); } if (null != LOCATION.getMouseEnterHandler()) locationIcon.setOnMouseEntered(new WeakEventHandler<>(LOCATION.getMouseEnterHandler())); if (null != LOCATION.getMousePressHandler()) locationIcon.setOnMousePressed(new WeakEventHandler<>(LOCATION.getMousePressHandler())); if (null != LOCATION.getMouseReleaseHandler()) locationIcon.setOnMouseReleased(new WeakEventHandler<>(LOCATION.getMouseReleaseHandler())); if (null != LOCATION.getMouseExitHandler()) locationIcon.setOnMouseExited(new WeakEventHandler<>(LOCATION.getMouseExitHandler())); locations.put(LOCATION, locationIcon); }
Example 2
Source File: FxmlControl.java From MyBox with Apache License 2.0 | 5 votes |
public static void setTooltip(final Node node, final Tooltip tooltip) { if (node instanceof Control) { removeTooltip((Control) node); } tooltip.setFont(new Font(AppVariables.sceneFontSize)); tooltip.setShowDelay(Duration.millis(10)); tooltip.setShowDuration(Duration.millis(360000)); tooltip.setHideDelay(Duration.millis(10)); Tooltip.install(node, tooltip); }
Example 3
Source File: TooltipSample.java From marathonv5 with Apache License 2.0 | 5 votes |
@Override public void start(Stage stage) { Scene scene = new Scene(new Group()); stage.setTitle("Tooltip Sample"); stage.setWidth(330); stage.setHeight(150); total.setFont(new Font("Arial", 20)); for (int i = 0; i < rooms.length; i++) { final CheckBox cb = cbs[i] = new CheckBox(rooms[i]); final Integer rate = rates[i]; final Tooltip tooltip = new Tooltip("$" + rates[i].toString()); tooltip.setFont(new Font("Arial", 16)); cb.setTooltip(tooltip); cb.selectedProperty().addListener((ObservableValue<? extends Boolean> ov, Boolean old_val, Boolean new_val) -> { if (cb.isSelected()) { sum = sum + rate; } else { sum = sum - rate; } total.setText("Total: $" + sum.toString()); }); } VBox vbox = new VBox(); vbox.getChildren().addAll(cbs); vbox.setSpacing(5); HBox root = new HBox(); root.getChildren().add(vbox); root.getChildren().add(total); root.setSpacing(40); root.setPadding(new Insets(20, 10, 10, 20)); ((Group) scene.getRoot()).getChildren().add(root); stage.setScene(scene); stage.show(); }
Example 4
Source File: World.java From worldfx with Apache License 2.0 | 5 votes |
public void addLocation(final Location LOCATION) { double x = (LOCATION.getLongitude() + 180) * (PREFERRED_WIDTH / 360) + MAP_OFFSET_X; double y = (PREFERRED_HEIGHT / 2) - (PREFERRED_WIDTH * (Math.log(Math.tan((Math.PI / 4) + (Math.toRadians(LOCATION.getLatitude()) / 2)))) / (2 * Math.PI)) + MAP_OFFSET_Y; FontIcon locationIcon = new FontIcon(null == LOCATION.getIconCode() ? locationIconCode : LOCATION.getIconCode()); locationIcon.setIconSize(LOCATION.getIconSize()); locationIcon.setTextOrigin(VPos.CENTER); locationIcon.setIconColor(null == LOCATION.getColor() ? getLocationColor() : LOCATION.getColor()); locationIcon.setX(x - LOCATION.getIconSize() * 0.5); locationIcon.setY(y); StringBuilder tooltipBuilder = new StringBuilder(); if (!LOCATION.getName().isEmpty()) tooltipBuilder.append(LOCATION.getName()); if (!LOCATION.getInfo().isEmpty()) tooltipBuilder.append("\n").append(LOCATION.getInfo()); String tooltipText = tooltipBuilder.toString(); if (!tooltipText.isEmpty()) { Tooltip tooltip = new Tooltip(tooltipText); tooltip.setFont(Font.font(10)); Tooltip.install(locationIcon, tooltip); } if (null != LOCATION.getMouseEnterHandler()) locationIcon.setOnMouseEntered(new WeakEventHandler<>(LOCATION.getMouseEnterHandler())); if (null != LOCATION.getMousePressHandler()) locationIcon.setOnMousePressed(new WeakEventHandler<>(LOCATION.getMousePressHandler())); if (null != LOCATION.getMouseReleaseHandler()) locationIcon.setOnMouseReleased(new WeakEventHandler<>(LOCATION.getMouseReleaseHandler())); if (null != LOCATION.getMouseExitHandler()) locationIcon.setOnMouseExited(new WeakEventHandler<>(LOCATION.getMouseExitHandler())); locations.put(LOCATION, locationIcon); }