本文整理汇总了Java中javafx.scene.control.Label.setPrefSize方法的典型用法代码示例。如果您正苦于以下问题:Java Label.setPrefSize方法的具体用法?Java Label.setPrefSize怎么用?Java Label.setPrefSize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javafx.scene.control.Label
的用法示例。
在下文中一共展示了Label.setPrefSize方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: start
import javafx.scene.control.Label; //导入方法依赖的package包/类
@Override
public void start(Stage stage) throws Exception {
// Parent root = FXMLLoader.load(getClass().getResource("MasonaryPane.fxml"));
JFXMasonryPane root = new JFXMasonryPane();
Scene scene = new Scene(root,300,250);
Random r = new Random();
for (int i=0; i<100; i++){
Label label = new Label();
label.setPrefSize(r.nextInt(200),r.nextInt(300));
label.setStyle("-fx-background-color : rgb("+r.nextInt(255)+","+r.nextInt(255)+","+r.nextInt(255)+")");
root.getChildren().add(label);
}
stage.setTitle("Masonary Pane");
stage.setScene(scene);
stage.show();
}
示例2: generate
import javafx.scene.control.Label; //导入方法依赖的package包/类
/**
* Generates a panel image form char.
* <p>First, this function converts ch to upper case if ch is lower case.</p>
* <p>Then, this generates javafx's image from ch.And return it.</p>
* You can fix the resolution of image through {@link capslock.CharPanelGenerator#PANEL_IMAGE_SIZE}
* and {@link capslock.CharPanelGenerator#FONT_SIZE}.
* @param ch パネルの生成に使う1文字.
* @param color 背景色.
* @return 生成されたパネル.
*/
static final Image generate(char ch, Color color){
final Label label = new Label(Character.toString(Character.toUpperCase(ch)));
label.setMinSize(PANEL_IMAGE_SIZE, PANEL_IMAGE_SIZE);
label.setMaxSize(PANEL_IMAGE_SIZE, PANEL_IMAGE_SIZE);
label.setPrefSize(PANEL_IMAGE_SIZE, PANEL_IMAGE_SIZE);
label.setFont(Font.font(FONT_SIZE));
label.setAlignment(Pos.CENTER);
label.setTextFill(Color.WHITE);
label.setBackground(new Background(new BackgroundFill(color, CornerRadii.EMPTY, Insets.EMPTY)));
final Scene scene = new Scene(new Group(label));
final WritableImage img = new WritableImage(PANEL_IMAGE_SIZE, PANEL_IMAGE_SIZE);
scene.snapshot(img);
return img ;
}
示例3: createBox
import javafx.scene.control.Label; //导入方法依赖的package包/类
private Node createBox(Cursor cursor) {
Label label = new Label(cursor.toString());
label.setAlignment(Pos.CENTER);
label.setPrefSize(85, 85);
label.setStyle("-fx-border-color: #aaaaaa; -fx-background-color: #dddddd;");
label.setCursor(cursor);
return label;
}
示例4: text
import javafx.scene.control.Label; //导入方法依赖的package包/类
private static Label text(Resolution res, YCbCr matrix, int col) {
Label l = new Label(Integer.toString(getLuma(matrix, col)));
l.setFont(font(res.height / 54));
l.setTextFill(gray(matrix.fromLumaCode(matrix.YMIN * 4)));
l.setTextAlignment(TextAlignment.CENTER);
l.setAlignment(Pos.CENTER);
l.setPrefSize(getW(res.width, col), getLabelH(res.height));
return l;
}
示例5: createPixel
import javafx.scene.control.Label; //导入方法依赖的package包/类
private Label createPixel()
{
Label pixel = new Label();
pixel.setPrefSize(PIXEL_SIZE, PIXEL_SIZE);
pixel.setStyle("-fx-background-color: " + OFF_COLOR);
return pixel;
}
示例6: LabelControl
import javafx.scene.control.Label; //导入方法依赖的package包/类
public LabelControl(String name) {
super(name, FlashboardSendableType.LABEL);
node = new VBox();
label = new Label(name + ": " + value);
label.setPrefSize(LABEL_WIDTH, LABEL_HEIGHT);
node.getChildren().add(label);
}
示例7: start
import javafx.scene.control.Label; //导入方法依赖的package包/类
@Override
public void start(Stage primaryStage) {
try {
// Image setting = new Image(getClass().getResourceAsStream("setting.png"j));
Image logoimg = new Image(getClass().getResourceAsStream("logo.png"));
// Button settingbtn = new Button("",new ImageView(setting));
// settingLabel.setStyle("-fx-background-color:#1d1d1d");
JFXButton logobtn = new JFXButton("",new ImageView(logoimg));
Label title = new Label(" Energy Saving System");
title.setFont(new Font(30));
title.setPrefSize(650, 60);
title.setStyle("-fx-background-color:#1d1d1d; \n -fx-text-fill:white ;");
HBox hbox = new HBox();
hbox.setStyle("-fx-background-color:#1d1d1d");
hbox.setSpacing(10);
hbox.setPadding(new Insets(10,10,10,10));
hbox.getChildren().addAll(logobtn,title);
BorderPane root = new BorderPane();
root.setTop(hbox);
JFXTabPane pane = new JFXTabPane();
pane.setSide(Side.RIGHT);
Tab tab1 = new Tab();
Tab tab2 = new Tab();
Tab tab3 = new Tab();
tab3.setText("Settings");
tab2.setText("Tweaks");
tab2.setContent(new Tweaks().getPane());
tab1.setText("Statistics");
tab1.setContent(new ChartControls().getPane());
pane.getTabs().addAll(tab1,tab2,tab3);
root.setCenter(pane);
Scene scene = new Scene(root,910,550);
scene.getStylesheets().add(getClass().getResource("application.css").toExternalForm());
primaryStage.setScene(scene);
primaryStage.show();
} catch(Exception e) {
e.printStackTrace();
}
}
示例8: produceLabel
import javafx.scene.control.Label; //导入方法依赖的package包/类
private Label produceLabel(String name){
Label label=new Label(name);
label.setPrefSize(PREF_LABEL_WIDTH, PREF_LABEL_HEIGHT);
return label;
}