本文整理汇总了Java中javafx.scene.control.Label.setText方法的典型用法代码示例。如果您正苦于以下问题:Java Label.setText方法的具体用法?Java Label.setText怎么用?Java Label.setText使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javafx.scene.control.Label
的用法示例。
在下文中一共展示了Label.setText方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: start
import javafx.scene.control.Label; //导入方法依赖的package包/类
public void start(Stage primaryStage, ScrollPane rootLayout) throws Exception {
primaryStage.setTitle("Change Hotkeys");
Scene myScene = new Scene(rootLayout);
ourStage = primaryStage;
myScene.addEventFilter(KeyEvent.KEY_PRESSED, new EventHandler<KeyEvent>() {
public void handle(KeyEvent event) {
if (changeHotkey) {
if (addHotkey(event, changeHotkeyFunction)) {
changeHotkey = false;
}
}
}
});
Label divider = new Label();
HBox labelHbox = new HBox(divider);
divider.setText("----These hotkeys are not changeable----");
labelHbox.setAlignment(Pos.CENTER);
for (String key : HOTKEYS) {
hotkeyVBox.getChildren().add(hotkeys.get(key).getHotkeyHBox());
}
hotkeyVBox.getChildren().add(labelHbox);
for (ImmutableHotkey hotkey : IMMUTABLE_HOTKEYS) {
hotkeyVBox.getChildren().add(hotkey.getHotkeyHBox());
}
primaryStage.setScene(myScene);
}
示例2: display
import javafx.scene.control.Label; //导入方法依赖的package包/类
public static void display(String title, String message) {
Stage window = new Stage();
window.initModality(Modality.APPLICATION_MODAL);
window.setTitle(title);
window.setMinWidth(250);
Label label = new Label();
label.setText(message);
Button closeButton = new Button("Close the window");
closeButton.setOnAction(e -> window.close());
VBox layout = new VBox(10);
layout.getChildren().addAll(label, closeButton);
layout.setAlignment(Pos.CENTER);
Scene scene = new Scene(layout);
window.setScene(scene);
window.setResizable(false);
window.showAndWait();
}
示例3: display
import javafx.scene.control.Label; //导入方法依赖的package包/类
public static void display(String title, String message)
{
Stage window= new Stage();
window.initModality(Modality.APPLICATION_MODAL);
window.setAlwaysOnTop(true);
window.getIcons().add(new Image("/pic/slogo.png"));
window.setTitle(title);
Label label= new Label();
label.setText(message);
label.setStyle("-fx-font-size:14px;");
ImageView imageView = new ImageView(ICON);
imageView.setFitWidth(40);
imageView.setFitHeight(40);
Label labelimage = new Label("",imageView);
// two buttons
Button okbtn= new Button("Ok");
okbtn.setOnAction(e -> {
answer= false;
window.close();
});
okbtn.setId("blue");
HBox hbox= new HBox(10);
hbox.setAlignment(Pos.CENTER_LEFT);
hbox.setPadding(new Insets(10,5,10,5));
hbox.getChildren().addAll(labelimage,label);
VBox layout= new VBox(15);
layout.setAlignment(Pos.CENTER_RIGHT);
layout.setPadding(new Insets(10,5,10,5));
layout.getChildren().addAll(hbox,okbtn);
layout.setStyle("-fx-background-color: linear-gradient(#E4EAA2, #9CD672);");
Scene scene= new Scene(layout);
window.setScene(scene);
scene.getStylesheets().add(SuccessMessage.class.getResource("confirm.css").toExternalForm());
window.setResizable(false);
window.showAndWait();
}
示例4: validate
import javafx.scene.control.Label; //导入方法依赖的package包/类
/**
* Validate the resource element.
*
* @param warningLabel the warning label
* @param element the element.
*/
@FXThread
protected void validate(@NotNull final Label warningLabel, @Nullable final T element) {
final Function<@NotNull C, @Nullable String> validator = getValidator();
if (validator == null) return;
final C object = element == null ? null : getObject(element);
final String message = object == null ? null : validator.apply(object);
if (message == null) {
warningLabel.setText(StringUtils.EMPTY);
warningLabel.setVisible(false);
} else {
warningLabel.setText(message);
warningLabel.setVisible(true);
}
}
示例5: reload
import javafx.scene.control.Label; //导入方法依赖的package包/类
/**
* Reload.
*/
protected void reload() {
final ImageChannelPreview textureTooltip = getTextureTooltip();
final Label textureLabel = getTextureLabel();
final ImageView preview = getTexturePreview();
final Path textureFile = getTextureFile();
if (textureFile == null) {
textureLabel.setText(Messages.MATERIAL_MODEL_PROPERTY_CONTROL_NO_TEXTURE);
preview.setImage(null);
textureTooltip.clean();
return;
}
final Path assetFile = notNull(getAssetFile(textureFile));
textureLabel.setText(assetFile.toString());
preview.setImage(IMAGE_MANAGER.getImagePreview(textureFile, 28, 28));
textureTooltip.showImage(textureFile);
}
示例6: initVBox
import javafx.scene.control.Label; //导入方法依赖的package包/类
private void initVBox(){
EnumerationNode node = (EnumerationNode) getRefNode();
vbox.setPadding(new Insets(5, 0, 5, 0));
vbox.setSpacing(5);
titlePane = new VBox();
titlePane.setSpacing(5);
firstLine = new Separator();
firstLine.setMaxWidth(node.getWidth());
type = new Label();
type.setFont(Font.font("Helvetica", FontWeight.BOLD, 13));
type.setText("<<" + node.getType().toLowerCase() + ">>");
type.setTextFill(Color.web("#4B6299"));
type.setAlignment(Pos.TOP_CENTER);
title = new Label();
title.setFont(Font.font("Verdana", FontWeight.BOLD, 12));
title.setManaged(false);
if(node.getTitle() != null) {
title.setText(node.getTitle());
title.setVisible(true);
title.setManaged(true);
}
title.setAlignment(Pos.BOTTOM_CENTER);
values = new Label(node.getValues());
values.setFont(Font.font("Verdana", 10));
titlePane.getChildren().add(type);
titlePane.getChildren().add(title);
vbox.getChildren().addAll(titlePane, firstLine, values);
}
示例7: reload
import javafx.scene.control.Label; //导入方法依赖的package包/类
@Override
protected void reload() {
super.reload();
final Label nameLabel = getNameLabel();
nameLabel.setText(getName());
}
示例8: createLabels
import javafx.scene.control.Label; //导入方法依赖的package包/类
/**
* Creates or updates the actual layout of the time axis.
* The layout can either be horizontal or vertical.
* The GridView is populated with columns/rows and labels are added accordingly.
* The labels show the time between this.timeStartProperty and this.timeEndProperty with
* this.timeStepsProperty in between.
* The time is formatted according to this.formatter.
*/
private void createLabels() {
this.getChildren().clear();
this.getRowConstraints().clear();
this.getColumnConstraints().clear();
for(LocalTime currentTime = getTimeStartProperty().get();
currentTime.isBefore(getTimeEndProperty().get()); ) {
// create a new label with the time
Label lblTime = new Label();
lblTime.setText(currentTime.format(getFormatter()));
lblTime.getStyleClass().add("time-axis-label");
// create a new row/column and add the label to it
if(horizontal) {
// center the label
lblTime.widthProperty().addListener(o -> lblTime.setTranslateX( -lblTime.widthProperty().getValue() / 2));
ColumnConstraints column = new ColumnConstraints(0, USE_COMPUTED_SIZE, Double.POSITIVE_INFINITY, Priority.SOMETIMES, HPos.LEFT, true);
this.getColumnConstraints().add(column);
this.add(lblTime, this.getColumnConstraints().size() - 1, 0);
} else {
// center the label
lblTime.heightProperty().addListener(o -> lblTime.setTranslateY( -lblTime.heightProperty().getValue() / 2));
RowConstraints row = new RowConstraints(0, USE_COMPUTED_SIZE, Double.POSITIVE_INFINITY, Priority.SOMETIMES, VPos.TOP, true);
this.getRowConstraints().add(row);
this.add(lblTime, 0, this.getRowConstraints().size() - 1);
}
// prevent overflows at midnight
LocalTime newTime = currentTime.plusMinutes(getTimeStepsProperty().get().toMinutes());
if(newTime.isAfter(currentTime)) {
currentTime = newTime;
} else {
break;
}
}
}
示例9: reload
import javafx.scene.control.Label; //导入方法依赖的package包/类
@Override
@FXThread
public void reload() {
super.reload();
final Function<T, String> function = getToStringFunction();
final Label propertyValueLabel = getPropertyValueLabel();
propertyValueLabel.setText(function == null ? String.valueOf(getPropertyValue()) :
function.apply(getPropertyValue()));
}
示例10: createInitForControls
import javafx.scene.control.Label; //导入方法依赖的package包/类
public void createInitForControls(final AnchorPane myPaneWithControls, final Label lbl_with_temperature) {
lbl_with_temperature.setText("Initial temperature: " + slider.getValue());
// Adding Listener to value property.
//
slider.valueProperty().addListener((observable, oldValue, newValue) -> {
// TODO: 10/30/2017 smth
lbl_with_temperature.setText("New temperature: " + newValue);
});
}
示例11: setPlayersInformation
import javafx.scene.control.Label; //导入方法依赖的package包/类
private void setPlayersInformation(Player p, Label playerLabel) {
FlowPane playerPane = (FlowPane) playerLabel.getParent();
if (playerPane.getChildren().size() == 2) {
playerPane.getChildren().remove(0);
}
Image img = new Image("resources/player/" + p.getColor() + ".png");
ImageView iv = new ImageView();
iv.setFitWidth(30.0);
iv.setPreserveRatio(true);
iv.setImage(img);
playerLabel.setText("Joueur " + p.getColor() + " > Ressources : " + p.getResources()
+ " | Nombre de Yacks : " + p.getEconomicScore());
playerPane.getChildren().add(0, iv);
}
示例12: validate
import javafx.scene.control.Label; //导入方法依赖的package包/类
@Override
@FXThread
protected void validate(@NotNull final Label warningLabel, @Nullable final ResourceElement element) {
super.validate(warningLabel, element);
final Function<@NotNull Path, @Nullable String> validator = getValidator();
final boolean visible = warningLabel.isVisible();
if (!visible && element instanceof FolderResourceElement) {
warningLabel.setText(Messages.ASSET_EDITOR_DIALOG_WARNING_SELECT_FILE);
warningLabel.setVisible(true);
} else if (validator == null) {
warningLabel.setVisible(false);
}
}
示例13: initializeHeadline
import javafx.scene.control.Label; //导入方法依赖的package包/类
private void initializeHeadline(final Component component) {
final Label headline = (Label) lookup("#headline");
final Circle indicator = (Circle) lookup("#indicator");
final Line line = (Line) lookup("#line");
line.setStroke(Color.GREY.getColor(Color.Intensity.I400));
// This is an project wide message that is not specific to a component
if(component == null) {
headline.setText("Project");
return;
}
headline.setText(component.getName());
headline.textProperty().bind(component.nameProperty());
final EventHandler<MouseEvent> onMouseEntered = event -> {
setCursor(Cursor.HAND);
headline.setStyle("-fx-underline: true;");
};
final EventHandler<MouseEvent> onMouseExited = event -> {
setCursor(Cursor.DEFAULT);
headline.setStyle("-fx-underline: false;");
};
final EventHandler<MouseEvent> onMousePressed = event -> {
CanvasController.setActiveComponent(component);
};
headline.setOnMouseEntered(onMouseEntered);
headline.setOnMouseExited(onMouseExited);
headline.setOnMousePressed(onMousePressed);
indicator.setOnMouseEntered(onMouseEntered);
indicator.setOnMouseExited(onMouseExited);
indicator.setOnMousePressed(onMousePressed);
final BiConsumer<Color, Color.Intensity> updateColor = (color, intensity) -> {
indicator.setFill(color.getColor(component.getColorIntensity()));
};
updateColor.accept(component.getColor(), component.getColorIntensity());
component.colorProperty().addListener((observable, oldColor, newColor) -> updateColor.accept(newColor, component.getColorIntensity()));
}
示例14: createIDTextField
import javafx.scene.control.Label; //导入方法依赖的package包/类
private void createIDTextField() {
id = new Label();
id.setText("Retreiving ID from server...");
}
示例15: buildMainMenu
import javafx.scene.control.Label; //导入方法依赖的package包/类
private void buildMainMenu(Group root, Scene scene, Dimension screenSize) {
// Main title
Label maintitle = new Label();
maintitle.setText("Chess Master");
maintitle.setFont(new Font("Arial", MAIN_TITLE_FONT_SIZE));
maintitle.setLayoutX(MAIN_TITLE_LEFT_PADDING);
maintitle.setLayoutY(MAIN_TITLE_TOP_PADDING);
root.getChildren().add(maintitle);
// Buttons
Group buttonsGroup = new Group();
// Start button.
Button choiceGameButton = new Button();
choiceGameButton.setLayoutX(screenSize.getWidth() * BUTTON_LEFT_PADDING);
choiceGameButton.setLayoutY(maintitle.getLayoutY() * 2);
choiceGameButton.setPrefSize(BUTTONS_WIDTH, BUTTONS_HEIGHT);
choiceGameButton.setText("Choose your game");
buttonsGroup.getChildren().add(choiceGameButton);
// Setting button.
Button settingButton = new Button();
settingButton.setLayoutX(screenSize.getWidth() * BUTTON_LEFT_PADDING);
settingButton.setLayoutY(choiceGameButton.getLayoutY() + BUTTONS_SPACE);
settingButton.setPrefSize(BUTTONS_WIDTH, BUTTONS_HEIGHT);
settingButton.setText("Settings");
buttonsGroup.getChildren().add(settingButton);
// Quit button.
Button quitButton = new Button();
quitButton.setLayoutX(screenSize.getWidth() * BUTTON_LEFT_PADDING);
quitButton.setLayoutY(settingButton.getLayoutY() + BUTTONS_SPACE);
quitButton.setPrefSize(BUTTONS_WIDTH, BUTTONS_HEIGHT);
quitButton.setText("Quit game");
quitButton.setOnAction(handle -> closeApp());
buttonsGroup.getChildren().add(quitButton);
root.getChildren().add(buttonsGroup);
// Copyright
Label copyright = new Label();
copyright.setText("All rights reserved, Nicolas GILLE, 2017");
copyright.setFont(new Font("Arial", 12));
copyright.setLayoutX(COPYRIGHT_LEFT_PADDING);
copyright.setLayoutY(COPYRIGHT_TOP_PADDING);
root.getChildren().add(copyright);
}