本文整理汇总了Java中javafx.scene.control.Label.setWrapText方法的典型用法代码示例。如果您正苦于以下问题:Java Label.setWrapText方法的具体用法?Java Label.setWrapText怎么用?Java Label.setWrapText使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javafx.scene.control.Label
的用法示例。
在下文中一共展示了Label.setWrapText方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createTimeLeftInfoBox
import javafx.scene.control.Label; //导入方法依赖的package包/类
private HBox createTimeLeftInfoBox( final TileViewModel build ) {
final HBox lastBuildInfoPart = new HBox( );
lastBuildInfoPart.setAlignment( Pos.CENTER );
final ImageView lastBuildIcon = new ImageView( UIUtils.createImage( "icons/timeLeft.png" ) );
lastBuildIcon.setPreserveRatio( true );
lastBuildIcon.setFitWidth( 32 );
final Label timeLeftLabel = new Label( );
timeLeftLabel.setMinWidth( 110 );
timeLeftLabel.setTextAlignment( CENTER );
timeLeftLabel.setAlignment( Pos.CENTER );
timeLeftLabel.setFont( UIUtils.font( 32, FontWeight.BOLD ) );
timeLeftLabel.setTextFill( Color.WHITE );
timeLeftLabel.setWrapText( true );
timeLeftLabel.setEffect( UIUtils.shadowEffect( ) );
timeLeftLabel.textProperty( ).bind( createStringBinding( ( ) -> {
final java.time.Duration timeLeft = build.timeLeftProperty( ).get( );
return ( timeLeft.isNegative( ) ? "+ " : "" ) + ( abs( timeLeft.toMinutes( ) ) + 1 ) + "\nmin";
}, build.timeLeftProperty( ) ) );
lastBuildInfoPart.getChildren( ).addAll( lastBuildIcon, timeLeftLabel );
return lastBuildInfoPart;
}
示例2: createBuildInformation
import javafx.scene.control.Label; //导入方法依赖的package包/类
private void createBuildInformation( ) {
final Label tileTitle = new Label( );
tileTitle.setFont( UIUtils.font( 50, FontWeight.BOLD ) );
tileTitle.setTextFill( Color.WHITE );
tileTitle.setPadding( new Insets( 5 ) );
tileTitle.setWrapText( true );
tileTitle.textProperty( ).bind( _model.displayedNameProperty( ) );
tileTitle.setEffect( UIUtils.shadowEffect( ) );
tileTitle.prefWidthProperty( ).bind( widthProperty( ) );
tileTitle.prefHeightProperty( ).bind( heightProperty( ) );
tileTitle.alignmentProperty( ).bind( createObjectBinding( ( ) -> _model.isLightMode( ) ? Pos.CENTER : CENTER_LEFT, _model.lightModeProperty( ) ) );
tileTitle.textAlignmentProperty( ).bind( createObjectBinding( ( ) -> _model.isLightMode( ) ? CENTER : LEFT, _model.lightModeProperty( ) ) );
HBox.setHgrow( tileTitle, Priority.SOMETIMES );
getChildren( ).add( tileTitle );
final VBox contextPart = createContextPart( );
contextPart.visibleProperty( ).bind( _model.lightModeProperty( ).not( ) );
contextPart.prefWidthProperty( ).bind( createIntegerBinding( ( ) -> contextPart.isVisible( ) ? 90 : 0, contextPart.visibleProperty( ) ) );
contextPart.prefHeightProperty( ).bind( heightProperty( ) );
contextPart.setMinSize( USE_PREF_SIZE, USE_PREF_SIZE );
contextPart.setMaxSize( USE_PREF_SIZE, USE_PREF_SIZE );
getChildren( ).add( contextPart );
}
示例3: mkRoot
import javafx.scene.control.Label; //导入方法依赖的package包/类
@Override
public Node mkRoot() {
try {
Parent node = FXMLLoader.load(getClass().getResource("/ComplexScene.fxml"));
node.setPickOnBounds(true);
node.setMouseTransparent(true);
WebView webview = (WebView) node.lookup("webview");
if(webview != null){
webview.getEngine().load("http://purecss3.net/doraemon/doraemon_css3.html");
}
GesturePane pane = new GesturePane(new SubScene(node, 500, 500));
VBox.setVgrow(pane, Priority.ALWAYS);
Label description = new Label("Zoom and scroll on the SubScene below, " +
"observe that controls in JavaFX are vectors " +
"and that lighting effects are respected" +
"(different zoom alters light distance).");
description.setWrapText(true);
description.setPadding(new Insets(16));
return new VBox(description, pane);
} catch (IOException e) {
throw new RuntimeException(e);
}
}
示例4: createMessageBox
import javafx.scene.control.Label; //导入方法依赖的package包/类
private void createMessageBox(Message message, Pane parent, Pos alignment) {
VBox vbox = new VBox();
vbox.setAlignment(alignment);
vbox.setPadding(new Insets(0, 0, 0, 5));
Label body = new Label();
body.setWrapText(true);
body.setText(message.getBody());
Label date = new Label();
date.setText(DATE_FORMAT.format(message.getDate()));
vbox.getChildren().addAll(body, date);
parent.getChildren().add(vbox);
}
示例5: init
import javafx.scene.control.Label; //导入方法依赖的package包/类
private void init(Stage primaryStage) {
Group root = new Group();
primaryStage.setScene(new Scene(root));
VBox vRoot = new VBox();
vRoot.setPadding(new Insets(8, 8, 8, 8));
vRoot.setSpacing(5);
htmlEditor = new HTMLEditor();
htmlEditor.setPrefSize(500, 245);
htmlEditor.setHtmlText(INITIAL_TEXT);
vRoot.getChildren().add(htmlEditor);
final Label htmlLabel = new Label();
htmlLabel.setMaxWidth(500);
htmlLabel.setWrapText(true);
ScrollPane scrollPane = new ScrollPane();
scrollPane.getStyleClass().add("noborder-scroll-pane");
scrollPane.setContent(htmlLabel);
scrollPane.setFitToWidth(true);
scrollPane.setPrefHeight(180);
Button showHTMLButton = new Button("Show the HTML below");
vRoot.setAlignment(Pos.CENTER);
showHTMLButton.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent arg0) {
htmlLabel.setText(htmlEditor.getHtmlText());
}
});
vRoot.getChildren().addAll(showHTMLButton, scrollPane);
root.getChildren().addAll(vRoot);
}
示例6: createBuildInformation
import javafx.scene.control.Label; //导入方法依赖的package包/类
private HBox createBuildInformation( ) {
final HBox tileContent = new HBox( );
tileContent.setAlignment( CENTER_LEFT );
final Label tileTitle = new Label( );
tileTitle.setFont( UIUtils.font( 50, FontWeight.BOLD ) );
tileTitle.setTextFill( Color.WHITE );
tileTitle.setPadding( new Insets( 5 ) );
tileTitle.setWrapText( true );
tileTitle.setEffect( UIUtils.shadowEffect( ) );
tileTitle.textProperty( ).bind( _model.displayedNameProperty( ) );
tileTitle.prefWidthProperty( ).bind( widthProperty( ) );
tileTitle.prefHeightProperty( ).bind( heightProperty( ) );
tileTitle.alignmentProperty( ).bind( createObjectBinding( ( ) -> _model.isLightMode( ) ? Pos.CENTER : CENTER_LEFT, _model.lightModeProperty( ) ) );
tileTitle.textAlignmentProperty( ).bind( createObjectBinding( ( ) -> _model.isLightMode( ) ? CENTER : LEFT, _model.lightModeProperty( ) ) );
HBox.setHgrow( tileTitle, Priority.SOMETIMES );
tileContent.getChildren( ).add( tileTitle );
final VBox contextPart = createContextPart( _model );
contextPart.visibleProperty( ).bind( _model.lightModeProperty( ).not( ) );
contextPart.prefWidthProperty( ).bind( createIntegerBinding( ( ) -> contextPart.isVisible( ) ? 145 : 0, contextPart.visibleProperty( ) ) );
contextPart.prefHeightProperty( ).bind( heightProperty( ) );
contextPart.setMinSize( USE_PREF_SIZE, USE_PREF_SIZE );
contextPart.setMaxSize( USE_PREF_SIZE, USE_PREF_SIZE );
tileContent.getChildren( ).add( contextPart );
return tileContent;
}
示例7: showMessage
import javafx.scene.control.Label; //导入方法依赖的package包/类
private static Optional showMessage(String title, String headerText, String contentText, Alert.AlertType type, ImageView icon, List<ButtonType> buttonTypeList, Pane pane) {
GraphicsDevice graphicsDevice = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();
pane.setDisable(true);
Alert alert = new Alert(type);
alert.setTitle(title);
alert.getDialogPane().setMaxHeight(graphicsDevice.getDisplayMode().getHeight() * 0.9);
alert.getDialogPane().setMaxWidth(graphicsDevice.getDisplayMode().getWidth() * 0.9);
if(icon != null) {
alert.setGraphic(icon);
}
alert.setHeaderText(headerText);
Label contentTextElement = new Label(contentText);
contentTextElement.setWrapText(true);
ScrollPane contentTextElementScrollPane = new ScrollPane(contentTextElement);
alert.getDialogPane().setContent(contentTextElementScrollPane);
if(buttonTypeList != null) {
alert.getButtonTypes().setAll(buttonTypeList);
}
Optional optional = alert.showAndWait();
alert.close();
pane.setDisable(false);
return optional;
}
示例8: updateItem
import javafx.scene.control.Label; //导入方法依赖的package包/类
@Override
protected void updateItem(Book item, boolean empty)
{
// required to ensure that cell displays properly
super.updateItem(item, empty);
if (empty || item == null)
{
setGraphic(null); // don't display anything
}
else
{
// create layout for cell
VBox vbox = new VBox(8.0); // 8 points of gap between controls
vbox.setAlignment(Pos.CENTER); // center contents horizontally
// configure thumbnail image
ImageView thumbImageView =
new ImageView(new Image(item.getThumbImage()));
thumbImageView.setPreserveRatio(true);
thumbImageView.setFitHeight(100.0); // thumbnail 100 points tall
vbox.getChildren().add(thumbImageView); // attach to Vbox
// configure text
Label label = new Label(item.getTitle());
label.setWrapText(true); // wrap if text too wide to fit in cell
label.setTextAlignment(TextAlignment.CENTER); // center text
vbox.getChildren().add(label); // attach to VBox
setGraphic(vbox); // attach custom layout to ListView cell
setPrefWidth(USE_PREF_SIZE); // use preferred size for cell width
}
}
示例9: createConversationSnippet
import javafx.scene.control.Label; //导入方法依赖的package包/类
protected VBox createConversationSnippet(final Participant participant, String snippet) {
VBox vbox = new VBox();
vbox.setPadding(new Insets(0, 0, 0, 5));
Label sender = new Label(participant.getName());
sender.setWrapText(true);
Label phoneNumber = new Label(participant.getPhoneNumber());
phoneNumber.setWrapText(true);
Label label = new Label(snippet);
label.setWrapText(true);
vbox.getChildren().addAll(sender, phoneNumber, label);
return vbox;
}
示例10: CalendarFXSamplerWelcome
import javafx.scene.control.Label; //导入方法依赖的package包/类
public CalendarFXSamplerWelcome() {
super("CalendarFX", new Label(""));
Label label = (Label) getContent();
label.setWrapText(true);
label.setMaxWidth(Double.MAX_VALUE);
label.setMaxHeight(Double.MAX_VALUE);
label.setTextAlignment(TextAlignment.CENTER);
label.setAlignment(Pos.CENTER);
label.setPadding(new Insets(50));
label.setText("Welcome to the CalendarFX sampler. This application allows you to quickly browse through the "
+ "various controls that are available in this framework. In each sample you can play around with the "
+ "properties and controls shown on the right-hand side.");
}
示例11: createTitleLabel
import javafx.scene.control.Label; //导入方法依赖的package包/类
/**
* The label used to show the title.
*
* @returns The title component.
*/
protected Label createTitleLabel() {
Label label = new Label();
label.setWrapText(true);
label.setMinSize(0, 0);
return label;
}
示例12: formatcomment
import javafx.scene.control.Label; //导入方法依赖的package包/类
public static BorderPane formatcomment(String timestamp, String comment){
BorderPane notice = new BorderPane();
notice.setPadding(new Insets(0,-20,0,10));
notice.setMaxWidth(340);
VBox noticeVB = new VBox(5);
noticeVB.setStyle("-fx-background-color: transparent; -fx-border-color: #333; -fx-border-width: 1,1,1,1; -fx-border-radius: 10; -fx-text-color: #333;");
Label commentLabel = new Label(comment);
commentLabel.setPadding(new Insets(5));
commentLabel.setFont(new Font("Cambria", 16));
commentLabel.setTextFill(Color.web("#191919"));
commentLabel.setWrapText(true);
commentLabel.setMaxWidth(320);
commentLabel.setAlignment(Pos.BOTTOM_LEFT);
Label time = new Label(timeStampChangeFormat.timeStampChangeFormat(timestamp));
time.setFont(new Font("Cambria", 12));
time.setTextFill(Color.web("#4c4c4c"));
time.setPadding(new Insets(5));
time.setMaxWidth(320);
time.setAlignment(Pos.BOTTOM_LEFT);
noticeVB.getChildren().addAll(commentLabel,time);
notice.setLeft(noticeVB);
noticeVB.setStyle("-fx-background-color: #fff");
return notice;
}
示例13: buildItemCell
import javafx.scene.control.Label; //导入方法依赖的package包/类
private Node buildItemCell(SocialMediaItem item) {
HBox hbox = new HBox();
InputStream resource = item.getClass().getResourceAsStream("icon.png");
if (resource != null) {
ImageView sourceImage = new ImageView();
sourceImage.setFitHeight(18);
sourceImage.setPreserveRatio(true);
sourceImage.setSmooth(true);
sourceImage.setCache(true);
sourceImage.setImage(new Image(resource));
hbox.getChildren().add(sourceImage);
}
if (item.getImage() != null) {
HBox picture = new HBox();
picture.setPadding(new Insets(0, 10, 0, 0));
ImageView imageView = new ImageView(item.getImage());
imageView.setPreserveRatio(true);
imageView.setFitWidth(150);
picture.getChildren().add(imageView);
hbox.getChildren().add(picture);
}
Label text = new Label(item.getBody());
text.setFont(Font.font(null, 20));
text.setWrapText(true);
hbox.getChildren().add(text);
return hbox;
}
示例14: prepareRatioGrid
import javafx.scene.control.Label; //导入方法依赖的package包/类
/**
* Note that JavaFx GridPane uses (col, row) instead of (row, col)
*/
private void prepareRatioGrid() {
squidSpeciesList = squidProject.getTask().getSquidSpeciesModelList();
indexOfBackgroundSpecies = -1;
ratiosGridPane.getRowConstraints().clear();
RowConstraints rowCon = new RowConstraints();
rowCon.setPrefHeight(BUTTON_HEIGHT);
ratiosGridPane.getRowConstraints().add(rowCon);
ratiosGridPane.getColumnConstraints().clear();
ColumnConstraints colcon = new ColumnConstraints(BUTTON_WIDTH);
colcon.setPrefWidth(BUTTON_WIDTH);
colcon.setHalignment(HPos.CENTER);
ratiosGridPane.getColumnConstraints().add(colcon);
for (int i = 0; i < squidSpeciesList.size(); i++) {
if (squidSpeciesList.get(i).getIsBackground()) {
indexOfBackgroundSpecies = squidSpeciesList.get(i).getMassStationIndex();
squidProject.getTask().setIndexOfBackgroundSpecies(indexOfBackgroundSpecies);
Text colText = new Text(squidSpeciesList.get(i).getIsotopeName());
colText.setFont(Font.font("Courier New", FontWeight.BOLD, 12));
ratiosGridPane.add(colText, 0, i + 1);
Text rowText = new Text(squidSpeciesList.get(i).getIsotopeName());
rowText.setFont(Font.font("Courier New", FontWeight.BOLD, 12));
ratiosGridPane.add(rowText, i + 1, 0);
} else {
Button colButton = new SquidRowColButton(i, -1, squidSpeciesList.get(i).getIsotopeName());
ratiosGridPane.add(colButton, 0, i + 1);
Button rowButton = new SquidRowColButton(-1, i, squidSpeciesList.get(i).getIsotopeName());
ratiosGridPane.add(rowButton, i + 1, 0);
}
Label corLabel = new Label("ROW /\n COL");
corLabel.setFont(Font.font("Courier New", FontWeight.BOLD, 2));
corLabel.setStyle(
" -fx-font-family: \"Courier New\", \"Lucida Sans\", \"Segoe UI\", Helvetica, Arial, sans-serif;\n"
+ " -fx-font-weight: bold;\n"
+ " -fx-font-size: 7pt;\n"
);
corLabel.setWrapText(true);
ratiosGridPane.add(corLabel, 0, 0);
ratiosGridPane.getRowConstraints().add(rowCon);
ratiosGridPane.getColumnConstraints().add(colcon);
}
populateRatioGrid();
// center in window
double width = primaryStageWindow.getScene().getWidth();
ratiosGridPane.setLayoutX((width - (squidSpeciesList.size() + 1) * BUTTON_WIDTH) / 2.0);
ratiosGridPane.setLayoutY(15);
}
示例15: mkRoot
import javafx.scene.control.Label; //导入方法依赖的package包/类
@Override
public Node mkRoot() {
Label description = new Label("GesturePane works in a JFXPanel too!");
description.setWrapText(true);
description.setPadding(new Insets(16));
Button button = new Button("Open Swing window");
button.setOnAction(e -> {
SwingUtilities.invokeLater(() -> {
try {
UIManager.setLookAndFeel(
UIManager.getSystemLookAndFeelClassName());
} catch (ClassNotFoundException |
InstantiationException |
IllegalAccessException |
UnsupportedLookAndFeelException ignored) {
// give up, doesn't matter
}
JLabel label = new JLabel("This window is a Swing JFrame with JFXPanel embedded " +
"in a BorderLayout");
label.setBorder(new EmptyBorder(10, 10, 10, 10));
JPanel ops = new JPanel();
JButton centre = new JButton("Centre image");
JButton x2 = new JButton("Zoom x2");
ops.add(centre);
ops.add(x2);
JFXPanel fxPanel = new JFXPanel();
JFrame frame = new JFrame("GesturePane in Swing");
frame.getContentPane().add(label, BorderLayout.NORTH);
frame.getContentPane().add(fxPanel, BorderLayout.CENTER);
frame.getContentPane().add(ops, BorderLayout.SOUTH);
frame.setSize(500, 500);
frame.setVisible(true);
frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
Platform.runLater(() -> {
GesturePane pane = new GesturePane(new ImageView(LenaSample.LENA));
Scene scene = new Scene(pane, frame.getWidth(), frame.getHeight());
fxPanel.setScene(scene);
centre.addActionListener(ae -> pane.animate(LenaSample.DURATION)
.interpolateWith(Interpolator.EASE_BOTH)
.centreOn(pane.viewportCentre()));
x2.addActionListener(ae -> pane.animate(LenaSample.DURATION)
.interpolateWith(Interpolator.EASE_BOTH)
.zoomBy(2, pane.targetPointAtViewportCentre()));
});
});
});
VBox.setVgrow(button, Priority.ALWAYS);
VBox box = new VBox(description, button);
box.setAlignment(Pos.CENTER);
return box;
}