本文整理汇总了Java中javafx.scene.control.Label.setLayoutX方法的典型用法代码示例。如果您正苦于以下问题:Java Label.setLayoutX方法的具体用法?Java Label.setLayoutX怎么用?Java Label.setLayoutX使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javafx.scene.control.Label
的用法示例。
在下文中一共展示了Label.setLayoutX方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: MyNode
import javafx.scene.control.Label; //导入方法依赖的package包/类
public MyNode(String name) {
text = new Label(name);
text.setStyle("-fx-border-color:black; -fx-padding:3px;");
text.setLayoutX(4);
text.setLayoutY(2);
getChildren().addAll(text);
}
示例2: addLabel
import javafx.scene.control.Label; //导入方法依赖的package包/类
public void addLabel(String text) {
// String resultText = "";
// String tempText = "";
// int iteration = 1;
//
// char[] countChars = text.toCharArray();
// double height = ((countChars.length % 39) + 1) * 20;
//
//
// System.out.println(countChars);
// for(int i = 0; i < countChars.length; i++) {
//
// if (i % 42 == 0 && i != 0) {
// resultText = resultText + countChars[i] + '\n';
// continue;
// }
//
// resultText += countChars[i];
// }
// System.out.println(resultText);
System.out.println(text);
Label label = new Label(text);
label.setMaxWidth(vbox.getMaxWidth());
label.setWrapText(true);
final double MAX_FONT_SIZE = 18.0; // define max font size you need
label.setFont(new Font(MAX_FONT_SIZE)); // set to Label
label.setTextFill(Color.color(Math.random(), Math.random(), Math.random()));
label.setLayoutX(0);
if(vbox.getChildren().size() >= 1) {
double yCordinate = vbox.getChildren().get(vbox.getChildren().size()-1).getBoundsInParent().getHeight();
// label.setLayoutY(vbox.getChildren().get(vbox.getChildren().size()-1).getLayoutY() + 50 + yCordinate);
}
this.vbox.getChildren().add(label);
// this.scrollPane.setMaxHeight(pane.getMaxHeight() + pane.getChildren().get(pane.getChildren().size()-1).getBoundsInParent().getHeight());
// scrollPane.setVvalue(1.0);
// if (pane.getChildren().get(pane.getChildren().size()-1).getLayoutY() > 450) {
// pane.setPrefHeight(pane.getChildren().get(pane.getChildren().size()-1).getLayoutY() + 50);
// }
//this.pane.getChildren().add(new Label)
}
示例3: 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);
}
示例4: createLinesAndCategories
import javafx.scene.control.Label; //导入方法依赖的package包/类
@SuppressWarnings("deprecation")
private void createLinesAndCategories(ArrayList<double[]> shapeCordsList) {
int index = 0;
for (int i = 0; i < categoriesName.length; i++) {
double xPlus = 0;
double yPlus = 0;
double x = shapeCordsList.get(0)[index];
double y = shapeCordsList.get(0)[index + 1];
HBox pane = new HBox();
Label categoryLabel = new Label(categoriesName[i]);
categoryLabel.setStyle("-fx-text-fill:black");
categoryLabel.setFont(Font.font(15));
pane.getChildren().add(categoryLabel);
@SuppressWarnings("unused")
Scene s = new Scene(pane);
categoryLabel.impl_processCSS(true);
double labelWidth = categoryLabel.prefWidth(-1);
double labelHeight = categoryLabel.prefHeight(-1);
pane.getChildren().clear();
if (x < xCenter) {
xPlus = -labelWidth;
}
if (y < yCenter) {
yPlus = -labelHeight;
}
categoryLabel.setLayoutX(x + xPlus);
categoryLabel.setLayoutY(y + yPlus);
getChildren().add(categoryLabel);
index = index + 2;
}
}