本文整理匯總了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;
}
}