javafx.scene.control.TextField#setTooltip ( )源码实例Demo

下面列出了javafx.scene.control.TextField#setTooltip ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: paintera   文件: ChannelInformation.java
public Node getNode()
{

	final TextField channels = new TextField();
	channels.setEditable(false);
	channels.setTooltip(new Tooltip("Channel selection"));
	channelSelection.addListener((obs, oldv, newv) -> channels.setText(String.join(", ", IntStream.of(newv).boxed().map(Object::toString).toArray(String[]::new))));


	MenuItem all = new MenuItem("_All");
	all.setOnAction(e -> channelSelection.set(range()));

	MenuItem revert = new MenuItem("_Revert");
	revert.setOnAction(e -> channelSelection.set(reverted(channelSelection.get())));

	MenuItem everyNth = new MenuItem("Every _Nth");
	everyNth.setOnAction(e -> everyNth(numChannels.get()).ifPresent(channelSelection::set));

	final MenuButton selectionButton = new MenuButton("_Select", null, all, revert, everyNth);

	HBox.setHgrow(channels, Priority.ALWAYS);
	return new VBox(
			new Label("Channel Settings"),
			new HBox(channels, selectionButton));
}
 
源代码2 项目: LogFX   文件: ColorChooser.java
private static TextField fieldFor( Rectangle colorRectangle,
                                   String toolTipText,
                                   Consumer<? super Color> onUpdate ) {
    TextField field = new TextField( colorRectangle.getFill().toString() );
    field.setTooltip( new Tooltip( toolTipText ) );
    field.setMinWidth( 30 );
    field.setMaxWidth( 114 );
    field.textProperty().addListener( ( ignore, oldValue, newValue ) -> {
        try {
            Color colorValue = Color.valueOf( newValue );
            colorRectangle.setFill( colorValue );
            field.getStyleClass().remove( "error" );
            onUpdate.accept( colorValue );
        } catch ( IllegalArgumentException e ) {
            if ( !field.getStyleClass().contains( "error" ) ) {
                field.getStyleClass().add( "error" );
            }
            log.debug( "Invalid color entered" );
        }
    } );
    return field;
}
 
源代码3 项目: LogFX   文件: HighlightOptions.java
Row( String pattern, Paint backgroundColor, Paint fillColor, boolean isFiltered ) {
    setSpacing( 5 );

    expressionField = new TextField( pattern );
    expressionField.setMinWidth( 300 );
    expressionField.setTooltip( new Tooltip( "Enter a regular expression." ) );

    bkgColorPicker = new ColorChooser( backgroundColor.toString(), "Enter the background color." );
    fillColorPicker = new ColorChooser( fillColor.toString(), "Enter the text color." );

    isFilteredBox = new CheckBox();
    isFilteredBox.setSelected( isFiltered );
    isFilteredBox.setTooltip( new Tooltip( "Include in filter" ) );

    InvalidationListener updater = ( ignore ) ->
            update( bkgColorPicker.getColor(), fillColorPicker.getColor(), isFilteredBox.selectedProperty().get() );

    bkgColorPicker.addListener( updater );
    fillColorPicker.addListener( updater );
    isFilteredBox.selectedProperty().addListener( updater );
    expressionField.textProperty().addListener( updater );

    setMinWidth( 500 );
}
 
源代码4 项目: oim-fx   文件: TooltipFrame.java
private void init() {

		this.setCenter(rootVBox);
		this.setTitle("登录");
		this.setWidth(380);
		this.setHeight(600);
		this.setRadius(10);

		rootVBox.getChildren().add(hBox1);
		rootVBox.getChildren().add(hBox2);
		rootVBox.getChildren().add(hBox3);
		rootVBox.getChildren().add(hBox4);

		Tooltip tooltip1 = new Tooltip();
		tooltip1.setText("账号");
		tooltip1.setHideOnEscape(true);

		TextField textField1 = new TextField();
		
		textField1.setTooltip(tooltip1);
		
		Button button1 = new Button();

		button1.setText("点击");
		button1.setOnAction(new EventHandler<ActionEvent>() {

			@Override
			public void handle(ActionEvent event) {
				tooltip1.show(TooltipFrame.this);
			}
		});
		hBox1.getChildren().add(textField1);
		hBox1.getChildren().add(button1);

	}
 
源代码5 项目: paintera   文件: PainteraAlerts.java
public static Alert versionDialog() {
	final TextField versionField = new TextField(Version.VERSION_STRING);
	versionField.setEditable(false);
	versionField.setTooltip(new Tooltip(versionField.getText()));
	final HBox versionBox = new HBox(new Label("Paintera Version"), versionField);
	HBox.setHgrow(versionField, Priority.ALWAYS);
	versionBox.setAlignment(Pos.CENTER);
	final Alert alert = PainteraAlerts.alert(Alert.AlertType.INFORMATION, true);
	alert.getDialogPane().setContent(versionBox);
	alert.setHeaderText("Paintera Version");
	alert.initModality(Modality.NONE);
	return alert;
}
 
源代码6 项目: mars-sim   文件: ChatBoxTimed.java
@Override
public void start(Stage primaryStage) {
    final Clock clock = new Clock(Duration.seconds(1), true);
    
    final BorderPane root = new BorderPane();
    final HBox controls = new HBox(5);
    controls.setAlignment(Pos.CENTER);
    controls.setPadding(new Insets(10));
    
    final TextField itemField = new TextField();
    itemField.setTooltip(new Tooltip("Type an item and press Enter"));
    controls.getChildren().add(itemField);
    
    final VBox items = new VBox(5);
    
    itemField.setOnAction(event -> {
        String text = itemField.getText();
        Label label = new Label();
        label.textProperty().bind(Bindings.format("%s (%s)", text, clock.getElapsedStringBinding()));
        items.getChildren().add(label);
        itemField.setText("");
    });
    
    final ScrollPane scroller = new ScrollPane();
    scroller.setContent(items);
    
    final Label currentTimeLabel = new Label();
    currentTimeLabel.textProperty().bind(Bindings.format("Current time: %s", clock.getTimeStringBinding()));
    
    root.setTop(controls);
    root.setCenter(scroller);
    root.setBottom(currentTimeLabel);
    
    Scene scene = new Scene(root, 600, 400);
    
    primaryStage.setTitle("Timed item display");
    primaryStage.setScene(scene);
    primaryStage.show();
}
 
源代码7 项目: Quelea   文件: WebPanel.java
private void setupNavigationBarContent() {
    back = new Button("", getButtonImageView("file:icons/arrow-back.png"));
    back.setOnMouseClicked(e -> {
        if (wd != null) {
            wd.back();
        }
    });
    forward = new Button("", getButtonImageView("file:icons/arrow-forward.png"));
    forward.setOnMouseClicked(e -> {
        if (wd != null) {
            wd.forward();
        }
    });
    reload = new Button("", getButtonImageView("file:icons/reload.png"));
    reload.setOnMouseClicked(e -> {
        if (wd != null) {
            wd.reload();
        }
    });
    url = new TextField();
    url.setPrefHeight(32);
    url.setMaxHeight(32);
    url.setStyle(""
            + "-fx-font-size: 14px;"
            + "-fx-font-weight: bold;"
            + "-fx-font-family: fantasy;");
    url.setTooltip(new Tooltip("Change URL"));
    url.setOnKeyReleased(e -> {
        if (e.getCode().equals(KeyCode.ENTER)) {
            if (wd != null) {
                wd.setUrl(url.getText());
            }
        }
    });
    go = new Button("", getButtonImageView("file:icons/send.png"));
    go.setOnMouseClicked(e -> {
        if (wd != null) {
            wd.setUrl(url.getText());
        }
    });
    plus = new Button("", getButtonImageView("file:icons/zoom-in.png"));
    plus.setOnMouseClicked(e -> {
        if (wd != null) {
            wd.zoom(true);
        }
    });
    minus = new Button("", getButtonImageView("file:icons/zoom-out.png"));
    minus.setOnMouseClicked(e -> {
        if (wd != null) {
            wd.zoom(false);
        }
    });
}
 
源代码8 项目: paintera   文件: LockFileAlreadyExistsDialog.java
public static void showDialog(final LockFile.UnableToCreateLock exception)
{
	final Alert alert = new Alert(AlertType.ERROR);
	alert.setTitle("Paintera");
	alert.setHeaderText("Unable to create lock file.");

	final Label instructions = new Label(
			"If no other Paintera instance is accessing the same project please delete lock file and try to " +
					"restart Paintera.");
	instructions.setWrapText(true);

	final GridPane  content      = new GridPane();
	final Label     fileLabel    = new Label("Lock File");
	final Label     messageLabel = new Label("Message");
	final TextField fileField    = new TextField(exception.getLockFile().getAbsolutePath());
	final TextField messageField = new TextField(exception.getMessage());
	fileField.setTooltip(new Tooltip(fileField.getText()));
	messageField.setTooltip(new Tooltip(messageField.getText()));

	fileField.setEditable(false);
	messageField.setEditable(false);

	GridPane.setHgrow(fileField, Priority.ALWAYS);
	GridPane.setHgrow(messageField, Priority.ALWAYS);

	content.add(fileLabel, 0, 0);
	content.add(messageLabel, 0, 1);
	content.add(fileField, 1, 0);
	content.add(messageField, 1, 1);

	final VBox contentBox = new VBox(instructions, content);

	alert.getDialogPane().setContent(contentBox);

	final StringWriter stringWriter = new StringWriter();
	exception.printStackTrace(new PrintWriter(stringWriter));
	final String   exceptionText = stringWriter.toString();
	final TextArea textArea      = new TextArea(exceptionText);
	textArea.setEditable(false);
	textArea.setWrapText(true);

	LOG.trace("Exception text (length={}): {}", exceptionText.length(), exceptionText);

	textArea.setMaxWidth(Double.MAX_VALUE);
	textArea.setMaxHeight(Double.MAX_VALUE);
	GridPane.setVgrow(textArea, Priority.ALWAYS);
	GridPane.setHgrow(textArea, Priority.ALWAYS);

	//		final GridPane expandableContent = new GridPane();
	//		expandableContent.setMaxWidth( Double.MAX_VALUE );
	//
	//		expandableContent.add( child, columnIndex, rowIndex );

	alert.getDialogPane().setExpandableContent(textArea);

	//		alert.setResizable( true );
	alert.showAndWait();
}
 
源代码9 项目: phoebus   文件: Palette.java
/** Create UI elements
 *  @return Top-level Node of the UI
 */
@SuppressWarnings("unchecked")
public Node create()
{
    final VBox palette = new VBox();

    final Map<WidgetCategory, Pane> palette_groups = createWidgetCategoryPanes(palette);
    groups = palette_groups.values();
    createWidgetEntries(palette_groups);

    final ScrollPane palette_scroll = new ScrollPane(palette);
    palette_scroll.setHbarPolicy(ScrollBarPolicy.NEVER);
    palette_scroll.setFitToWidth(true);

    // TODO Determine the correct size for the main node
    // Using 2*PREFERRED_WIDTH was determined by trial and error
    palette_scroll.setMinWidth(PREFERRED_WIDTH + 12);
    palette_scroll.setPrefWidth(PREFERRED_WIDTH);

    // Copy the widgets, i.e. the children of each palette_group,
    // to the userData.
    // Actual children are now updated based on search by widget name
    palette_groups.values().forEach(group -> group.setUserData(new ArrayList<Node>(group.getChildren())));

    final TextField searchField = new ClearingTextField();
    searchField.setPromptText(Messages.SearchTextField);
    searchField.setTooltip(new Tooltip(Messages.WidgetFilterTT));
    searchField.setPrefColumnCount(9);
    searchField.textProperty().addListener( ( observable, oldValue, search_text ) ->
    {
        final String search = search_text.toLowerCase().trim();
        palette_groups.values().stream().forEach(group ->
        {
            group.getChildren().clear();
            final List<Node> all_widgets = (List<Node>)group.getUserData();
            if (search.isEmpty())
                group.getChildren().setAll(all_widgets);
            else
                group.getChildren().setAll(all_widgets.stream()
                                                      .filter(node ->
                                                      {
                                                         final String text = ((ToggleButton) node).getText().toLowerCase();
                                                         return text.contains(search);
                                                      })
                                                     .collect(Collectors.toList()));
        });
    });
    HBox.setHgrow(searchField, Priority.NEVER);

    final HBox toolsPane = new HBox(6);
    toolsPane.setAlignment(Pos.CENTER_RIGHT);
    toolsPane.setPadding(new Insets(6));
    toolsPane.getChildren().add(searchField);

    BorderPane paletteContainer = new BorderPane();
    paletteContainer.setTop(toolsPane);
    paletteContainer.setCenter(palette_scroll);

    return paletteContainer;
}
 
源代码10 项目: phoebus   文件: SelectedWidgetUITracker.java
/** Create an inline editor
 *
 *  <p>Depending on the widget's properties, it will edit
 *  the PV name or the text.
 *
 *  @param widget Widget on which to create an inline editor
 */
private void createInlineEditor(final Widget widget)
{
    // Check for an inline-editable property
    Optional<WidgetProperty<String>> check;

    // Defaulting to PV name or text property with some hard-coded exceptions.
    // Alternative if the list of hard-coded widgets grows:
    // Add Widget#getInlineEditableProperty()
    if (widget instanceof ActionButtonWidget)
        check = Optional.of(((ActionButtonWidget) widget).propText());
    else if (widget instanceof GroupWidget)
        check = Optional.of(((GroupWidget) widget).propName());
    else
        check = widget.checkProperty(CommonWidgetProperties.propPVName);
    if (! check.isPresent())
        check = widget.checkProperty(CommonWidgetProperties.propText);
    if (! check.isPresent())
        return;

    // Create text field, aligned with widget, but assert minimum size
    final MacroizedWidgetProperty<String> property = (MacroizedWidgetProperty<String>)check.get();
    inline_editor = new TextField(property.getSpecification());
    // 'Managed' text field would assume some default size,
    // but we set the exact size in here
    inline_editor.setManaged(false);
    inline_editor.setPromptText(property.getDescription()); // Not really shown since TextField will have focus
    inline_editor.setTooltip(new Tooltip(property.getDescription()));
    inline_editor.relocate(tracker.getX(), tracker.getY());
    inline_editor.resize(Math.max(100, tracker.getWidth()), Math.max(20, tracker.getHeight()));
    getChildren().add(inline_editor);

    // Add autocomplete menu if editing property PVName
    if (property.getName().equals(CommonWidgetProperties.propPVName.getName()))
        PVAutocompleteMenu.INSTANCE.attachField(inline_editor);

    // On enter or lost focus, update the property. On Escape, just close.
    final ChangeListener<? super Boolean> focused_listener = (prop, old, focused) ->
    {
        if (! focused)
        {
            if (!property.getSpecification().equals(inline_editor.getText()))
                undo.execute(new SetMacroizedWidgetPropertyAction(property, inline_editor.getText()));
            // Close when focus lost
            closeInlineEditor();
        }
    };

    inline_editor.setOnAction(event ->
    {
        undo.execute(new SetMacroizedWidgetPropertyAction(property, inline_editor.getText()));
        inline_editor.focusedProperty().removeListener(focused_listener);
        closeInlineEditor();
    });

    inline_editor.setOnKeyPressed(event ->
    {
        switch (event.getCode())
        {
        case ESCAPE:
            event.consume();
            inline_editor.focusedProperty().removeListener(focused_listener);
            closeInlineEditor();
        default:
        }
    });

    inline_editor.focusedProperty().addListener(focused_listener);

    inline_editor.selectAll();
    inline_editor.requestFocus();
}
 
源代码11 项目: phoebus   文件: AddPVDialog.java
private Node createContent(final Model model, final int count)
{
    final GridPane layout = new GridPane();
    // layout.setGridLinesVisible(true);
    layout.setHgap(5);
    layout.setVgap(5);
    final ColumnConstraints stay = new ColumnConstraints();
    final ColumnConstraints fill = new ColumnConstraints();
    fill.setHgrow(Priority.ALWAYS);
    layout.getColumnConstraints().addAll(stay, stay, fill);

    axis_options = FXCollections.observableArrayList(model.getAxes().stream().map(AxisConfig::getName).collect(Collectors.toList()));
    axis_options.add(0, Messages.AddPV_NewOrEmptyAxis);

    int row = -1;
    for (int i=0; i<count; ++i)
    {
        final String nm = count == 1 ? Messages.Name : Messages.Name + " " + (i+1);
        layout.add(new Label(nm), 0, ++row);
        final TextField name = new TextField();
        name.textProperty().addListener(event -> checkDuplicateName(name));
        name.setTooltip(new Tooltip(formula ? Messages.AddFormula_NameTT : Messages.AddPV_NameTT));
        if (! formula)
            PVAutocompleteMenu.INSTANCE.attachField(name);
        names.add(name);
        layout.add(name, 1, row, 2, 1);

        if (! formula)
        {
            layout.add(new Label(Messages.AddPV_Period), 0, ++row);
            final TextField period = new TextField(Double.toString(Preferences.scan_period));
            period.setTooltip(new Tooltip(Messages.AddPV_PeriodTT));
            periods.add(period);
            period.setDisable(true);
            layout.add(period, 1, row);

            final CheckBox monitor = new CheckBox(Messages.AddPV_OnChange);
            monitor.setTooltip(new Tooltip(Messages.AddPV_OnChangeTT));
            monitor.setSelected(true);
            monitors.add(monitor);
            monitor.setOnAction(event -> period.setDisable(monitor.isSelected()));
            layout.add(monitors.get(i), 2, row);
        }

        layout.add(new Label(Messages.AddPV_Axis), 0, ++row);
        final ChoiceBox<String> axis = new ChoiceBox<>(axis_options);
        axis.setTooltip(new Tooltip(Messages.AddPV_AxisTT));
        axis.getSelectionModel().select(0);
        axes.add(axis);
        layout.add(axes.get(i), 1, row);

        layout.add(new Separator(), 0, ++row, 3, 1);
    }
    return layout;
}
 
源代码12 项目: bisq   文件: BsqAddressTextField.java
public BsqAddressTextField() {
    TextField textField = new BisqTextField();
    textField.setId("address-text-field");
    textField.setEditable(false);
    textField.textProperty().bind(address);
    String tooltipText = Res.get("addressTextField.copyToClipboard");
    textField.setTooltip(new Tooltip(tooltipText));

    textField.setOnMousePressed(event -> wasPrimaryButtonDown = event.isPrimaryButtonDown());
    textField.setOnMouseReleased(event -> {
        if (wasPrimaryButtonDown && address.get() != null && address.get().length() > 0) {
            Utilities.copyToClipboard(address.get());
            Notification walletFundedNotification = new Notification()
                    .notification(Res.get("addressTextField.addressCopiedToClipboard"))
                    .hideCloseButton()
                    .autoClose();

            walletFundedNotification.show();
        }

        wasPrimaryButtonDown = false;
    });

    textField.focusTraversableProperty().set(focusTraversableProperty().get());
    //TODO app wide focus
    //focusedProperty().addListener((ov, oldValue, newValue) -> textField.requestFocus());


    Label copyIcon = new Label();
    copyIcon.setLayoutY(3);
    copyIcon.getStyleClass().addAll("icon", "highlight");
    copyIcon.setTooltip(new Tooltip(Res.get("addressTextField.copyToClipboard")));
    AwesomeDude.setIcon(copyIcon, AwesomeIcon.COPY);
    copyIcon.setOnMouseClicked(e -> GUIUtil.showFeeInfoBeforeExecute(() -> {
        if (address.get() != null && address.get().length() > 0)
            Utilities.copyToClipboard(address.get());
    }));

    AnchorPane.setRightAnchor(copyIcon, 5.0);
    AnchorPane.setRightAnchor(textField, 30.0);
    AnchorPane.setLeftAnchor(textField, 0.0);

    getChildren().addAll(textField, copyIcon);
}