3

I have guidance text in my app, which I put it in the label and is child of scrollpane. But the text is too long and I cannot by the scroll bar to get all text in the label. Any idea how to set the measure of scrollbar of scrollpane to get whole text in the label. I have used JavaFX Scene Builder.

user3770144
  • 105
  • 1
  • 2
  • 12
  • It's hard to say without seeing some code, but most likely you need to set the max width (and possibly height) of the label. You might also consider using a text field or text area with `setEditable(false)` instead of a label. – James_D Oct 03 '14 at 18:36
  • 1
    ref this solution http://stackoverflow.com/questions/18699789/javafx-2-word-wrapping-doesnt-work-in-scrollpane – Reegan Miranda Oct 04 '14 at 09:06

1 Answers1

5

I think this is for sample code in text wrapping using scroll pane.Just refer this.

/*
 * 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);
    }

}
Reegan Miranda
  • 2,879
  • 6
  • 43
  • 55