gpt4 book ai didi

javafx - 如何为标签设置滚动 Pane 的滚动条

转载 作者:行者123 更新时间:2023-12-05 03:14:12 25 4
gpt4 key购买 nike

我的应用程序中有指导文本,我将其放在标签中并且是滚动 Pane 的子项。但是文本太长,我无法通过滚动条获取标签中的所有文本。知道如何设置滚动 Pane 的滚动条尺寸以获取标签中的整个文本。我使用过 JavaFX Scene Builder。

最佳答案

我认为这是使用滚动 Pane 在文本换行中的示例代码。请引用它。

/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package comboboxeditable;

import javafx.application.Application;
import javafx.scene.Node;
import javafx.scene.Scene;
import javafx.scene.control.ScrollPane;
import javafx.scene.text.Text;
import javafx.stage.Stage;

/**
*
* @author reegan
*/
public class TextWrapping extends Application {

Node sub;

@Override
public void start(Stage primaryStage) {
ScrollPane root = new ScrollPane();
Scene scene = new Scene(root, 300, 250);
Text text = new Text("The look and feel of JavaFX applications "
+ "can be customized. Cascading Style Sheets (CSS) separate "
+ "appearance and style from implementation so that developers can "
+ "concentrate on coding. Graphic designers can easily "
+ "customize the appearance and style of the application "
+ "through the CSS. If you have a web design background,"
+ " or if you would like to separate the user interface (UI) "
+ "and the back-end logic, then you can develop the presentation"
+ " aspects of the UI in the FXML scripting language and use Java "
+ "code for the application logic. If you prefer to design UIs "
+ "without writing code, then use JavaFX Scene Builder. As you design the UI, "
+ "Scene Builder creates FXML markup that can be ported to an Integrated Development "
+ "Environment (IDE) so that developers can add the business logic.");
text.wrappingWidthProperty().bind(scene.widthProperty());
root.setFitToWidth(true);
root.setContent(text);
primaryStage.setTitle("Hello World!");
primaryStage.setScene(scene);
primaryStage.show();
}

/**
* @param args the command line arguments
*/
public static void main(String[] args) {
launch(args);
}

}

关于javafx - 如何为标签设置滚动 Pane 的滚动条,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26183898/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com