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


Java Label.setPrefSize方法代碼示例

本文整理匯總了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();
	}
 
開發者ID:naeemkhan12,項目名稱:JavaFx-Material-Design,代碼行數:19,代碼來源:Main.java

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

示例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;
}
 
開發者ID:jalian-systems,項目名稱:marathonv5,代碼行數:9,代碼來源:CursorSample.java

示例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;
}
 
開發者ID:testing-av,項目名稱:testing-video,代碼行數:10,代碼來源:BlackLevelBase.java

示例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;
}
 
開發者ID:dhawal9035,項目名稱:WebPLP,代碼行數:9,代碼來源:SevenSegmentPanel.java

示例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);
}
 
開發者ID:Flash3388,項目名稱:FlashLib,代碼行數:8,代碼來源:LabelControl.java

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

示例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;
}
 
開發者ID:LtubSalad,項目名稱:voogasalad-ltub,代碼行數:6,代碼來源:VariableSetter.java


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