import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.ButtonBuilder;
import javafx.scene.control.LabelBuilder;
import javafx.scene.control.OverrunStyle;
import javafx.scene.layout.GridPane;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;
public class TextOverrun extends Application {
public static void main(String[] args) {
launch(args);
}
@Override
public void start(Stage stage) throws Exception {
String text = "one two three four five six seven eight nine";
VBox root = new VBox(20d);
int row = 0;
int col = 0;
for (final OverrunStyle overrun : new OverrunStyle[] {OverrunStyle.CLIP, OverrunStyle.ELLIPSIS}) {
VBox vb = new VBox(5d);
vb.getChildren().add(LabelBuilder.create().text("[" + overrun + "]").build());
Button btn = ButtonBuilder.create()
.text(text)
.textOverrun(overrun)
.wrapText(false)
.maxHeight(20)
.maxWidth(150)
.build();
vb.getChildren().add(btn);
root.getChildren().add(vb);
}
Scene scene = new Scene(root);
stage.setScene(scene);
stage.show();
}
}
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.ButtonBuilder;
import javafx.scene.control.LabelBuilder;
import javafx.scene.control.OverrunStyle;
import javafx.scene.layout.GridPane;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;
public class TextOverrun extends Application {
public static void main(String[] args) {
launch(args);
}
@Override
public void start(Stage stage) throws Exception {
String text = "one two three four five six seven eight nine";
VBox root = new VBox(20d);
int row = 0;
int col = 0;
for (final OverrunStyle overrun : new OverrunStyle[] {OverrunStyle.CLIP, OverrunStyle.ELLIPSIS}) {
VBox vb = new VBox(5d);
vb.getChildren().add(LabelBuilder.create().text("[" + overrun + "]").build());
Button btn = ButtonBuilder.create()
.text(text)
.textOverrun(overrun)
.wrapText(false)
.maxHeight(20)
.maxWidth(150)
.build();
vb.getChildren().add(btn);
root.getChildren().add(vb);
}
Scene scene = new Scene(root);
stage.setScene(scene);
stage.show();
}
}