當前位置: 首頁>>代碼示例>>Java>>正文


Java Label.setText方法代碼示例

本文整理匯總了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);
}
 
開發者ID:ForJ-Latech,項目名稱:fwm,代碼行數:27,代碼來源:HotkeyController.java

示例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();
}
 
開發者ID:omniplatypus,項目名稱:Projeto-IP2,代碼行數:23,代碼來源:AlertBox.java

示例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();
}
 
開發者ID:mikemacharia39,項目名稱:gatepass,代碼行數:39,代碼來源:SuccessMessage.java

示例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);
    }
}
 
開發者ID:JavaSaBr,項目名稱:jmonkeybuilder,代碼行數:24,代碼來源:BaseAssetEditorDialog.java

示例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);
}
 
開發者ID:JavaSaBr,項目名稱:jmonkeybuilder,代碼行數:25,代碼來源:ChooseTextureControl.java

示例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);
}
 
開發者ID:kaanburaksener,項目名稱:octoBubbles,代碼行數:38,代碼來源:EnumerationNodeView.java

示例7: reload

import javafx.scene.control.Label; //導入方法依賴的package包/類
@Override
protected void reload() {
    super.reload();

    final Label nameLabel = getNameLabel();
    nameLabel.setText(getName());
}
 
開發者ID:JavaSaBr,項目名稱:jmonkeybuilder,代碼行數:8,代碼來源:NamedChooseTextureControl.java

示例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;
        }
    }
}
 
開發者ID:Jibbow,項目名稱:FastisFX,代碼行數:47,代碼來源:TimeAxis.java

示例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()));
}
 
開發者ID:JavaSaBr,項目名稱:jmonkeybuilder,代碼行數:12,代碼來源:DefaultPropertyControl.java

示例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);
    });

}
 
開發者ID:Evegen55,項目名稱:main_carauto_board,代碼行數:11,代碼來源:ClimateControlController.java

示例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);
}
 
開發者ID:sebastienscout,項目名稱:Himalaya-JavaFX,代碼行數:15,代碼來源:MainFXMLController.java

示例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);
    }
}
 
開發者ID:JavaSaBr,項目名稱:jmonkeybuilder,代碼行數:16,代碼來源:FileAssetEditorDialog.java

示例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()));
}
 
開發者ID:ulriknyman,項目名稱:H-Uppaal,代碼行數:45,代碼來源:MessageCollectionPresentation.java

示例14: createIDTextField

import javafx.scene.control.Label; //導入方法依賴的package包/類
private void createIDTextField() {
    id = new Label();
    id.setText("Retreiving ID from server...");
}
 
開發者ID:luisbraganca,項目名稱:file-transfer,代碼行數:5,代碼來源:ReceiveNetPane.java

示例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);
}
 
開發者ID:Kero76,項目名稱:chess-master,代碼行數:47,代碼來源:View.java


注:本文中的javafx.scene.control.Label.setText方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。