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