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


Java HBox.setPrefWidth方法代碼示例

本文整理匯總了Java中javafx.scene.layout.HBox.setPrefWidth方法的典型用法代碼示例。如果您正苦於以下問題:Java HBox.setPrefWidth方法的具體用法?Java HBox.setPrefWidth怎麽用?Java HBox.setPrefWidth使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javafx.scene.layout.HBox的用法示例。


在下文中一共展示了HBox.setPrefWidth方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: initBoxes

import javafx.scene.layout.HBox; //導入方法依賴的package包/類
private void initBoxes(Pane root, Scene scene) {
    VBox vBox = Nodes.TEXT_VBOX;
    HBox hBox = Nodes.TEXTBAR_HBOX;
    ScrollPane scrollPane = Nodes.SCROLL_PANE;

    vBox.setTranslateY(10);
    vBox.setTranslateX(10);
    vBox.prefWidthProperty().bind(scene.widthProperty().subtract(10));
    vBox.prefHeightProperty().bind(scene.heightProperty().subtract(20).subtract(preferences.getDouble("textbar-height")));
    vBox.setSpacing((preferences.getDouble("messages-spacing-level") - 1)*10-5);


    hBox.setPrefWidth(scene.getWidth());
    hBox.setPrefHeight(preferences.getDouble("textbar-height"));
    hBox.setTranslateY(scene.getHeight() - hBox.getPrefHeight());
    hBox.setSpacing(20);

    root.widthProperty().addListener(o -> hBox.setPrefWidth(root.getWidth()));
    root.heightProperty().addListener(o -> hBox.setTranslateY(scene.getHeight() - Nodes.TEXTBAR_HBOX.getPrefHeight()));

    scrollPane.setContent(vBox);
    scrollPane.setHbarPolicy(ScrollPane.ScrollBarPolicy.NEVER);
    scrollPane.setVbarPolicy(ScrollPane.ScrollBarPolicy.NEVER);
    scrollPane.setTranslateX(vBox.getTranslateX());
    scrollPane.setTranslateY(vBox.getTranslateY());
    scrollPane.maxWidthProperty().bind(vBox.prefWidthProperty());
    scrollPane.prefWidthProperty().bind(vBox.prefWidthProperty());
    scrollPane.prefHeightProperty().bind(vBox.prefHeightProperty());
    scrollPane.setFitToWidth(true);
    scrollPane.setFitToHeight(true);
}
 
開發者ID:iAmGio,項目名稱:jrfl,代碼行數:32,代碼來源:Jrfl.java

示例2: setupArchitectureManagementVisuals

import javafx.scene.layout.HBox; //導入方法依賴的package包/類
/**
 * Create the different buttons for the architecture management and add the desired actions to them
 */
private void setupArchitectureManagementVisuals() {
    HBox buttons = new HBox();

    Button configButton = new Button("Config");
    Button startButton = new Button("Start");
    Button pauseButton = new Button("Pause");
    Button resumeButton = new Button("Resume");
    Button stopButton = new Button("Stop");

    buttons.getChildren().addAll(configButton, startButton, pauseButton, resumeButton, stopButton);

    BorderPane borderPane = new BorderPane();
    borderPane.setPrefHeight(canvas.getScene().getHeight());
    borderPane.setPrefWidth(canvas.getScene().getWidth());

    Pane space = new Pane();
    space.setMinSize(1, 1);
    HBox.setHgrow(space, Priority.ALWAYS);

    HBox container = new HBox();
    container.setPrefWidth(canvas.getScene().getWidth());

    container.getChildren().addAll(space, buttons);
    borderPane.setBottom(container);
    root.getChildren().add(borderPane);

    configButton.setOnMouseClicked(new ArchitectureButtonEventHandler(SimulationAction.CONFIG, publisher));
    startButton.setOnMouseClicked(new ArchitectureButtonEventHandler(SimulationAction.START, publisher));
    stopButton.setOnMouseClicked(new ArchitectureButtonEventHandler(SimulationAction.STOP, publisher));
    pauseButton.setOnMouseClicked(new ArchitectureButtonEventHandler(SimulationAction.PAUSE, publisher));
    resumeButton.setOnMouseClicked(new ArchitectureButtonEventHandler(SimulationAction.RESUME, publisher));
}
 
開發者ID:INAETICS,項目名稱:Drones-Simulator,代碼行數:36,代碼來源:Game.java

示例3: initTabProcesses

import javafx.scene.layout.HBox; //導入方法依賴的package包/類
private Node initTabProcesses() {
	userProcessesList = FXCollections.observableArrayList();
	allProcessesList = FXCollections.observableArrayList();
       
	ProcessesUtil.getProcesses(allProcessesList, true);
       ProcessesUtil.getProcesses(userProcessesList, false);
       
       TableColumn pidCol = new TableColumn("PID");
       TableColumn nameCol = new TableColumn("Nome do processo");
	TableColumn userCol = new TableColumn("Usuário");
       TableColumn cpuCol = new TableColumn("CPU (%)");
	TableColumn memCol = new TableColumn("Memória (%)");
       
       pidCol.setCellValueFactory(
           new PropertyValueFactory<>("pid")
       );
	
	nameCol.setCellValueFactory(
           new PropertyValueFactory<>("readableName")
       );
	
	userCol.setCellValueFactory(
           new PropertyValueFactory<>("user")
       );
	
       cpuCol.setCellValueFactory(
           new PropertyValueFactory<>("CPU")
       );
	
	memCol.setCellValueFactory(
           new PropertyValueFactory<>("MEM")
       );
	
       viewProcesses = new TableView();
       viewProcesses.setEditable(false);
       viewProcesses.getColumns().addAll(pidCol, nameCol, userCol, cpuCol, memCol);
       viewProcesses.setItems(userProcessesList);
       
       viewProcesses.setOnMousePressed(mouseEventHandler);
       
       checkBoxAllProcesses = new CheckBox("Processos de todos usuários");
       checkBoxAllProcesses.setOnAction(actionEventHandler);
       
       inputFilter = new TextField();
	inputFilter.textProperty().addListener(this);
	
	Label labelFilter = new Label("Filtrar:");
	labelFilter.setPadding(new Insets(0, 10, 0, 0));
       
	HBox hBoxFilter = new HBox(labelFilter, inputFilter);
	hBoxFilter.setAlignment(Pos.BASELINE_RIGHT);
	HBox.setHgrow(hBoxFilter, Priority.ALWAYS); 
	
       HBox hBoxOptions = new HBox(checkBoxAllProcesses, hBoxFilter);
       hBoxOptions.setPrefWidth(prefWidth);
       hBoxOptions.setPadding(new Insets(10));
	
	return new VBox(viewProcesses, hBoxOptions);
}
 
開發者ID:dhiogoboza,項目名稱:SystemMonitorJFX,代碼行數:60,代碼來源:MainStage.java


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