当前位置: 首页>>代码示例>>Java>>正文


Java ChoiceBox.setPrefWidth方法代码示例

本文整理汇总了Java中javafx.scene.control.ChoiceBox.setPrefWidth方法的典型用法代码示例。如果您正苦于以下问题:Java ChoiceBox.setPrefWidth方法的具体用法?Java ChoiceBox.setPrefWidth怎么用?Java ChoiceBox.setPrefWidth使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javafx.scene.control.ChoiceBox的用法示例。


在下文中一共展示了ChoiceBox.setPrefWidth方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: buildEyeTrackerConfigChooser

import javafx.scene.control.ChoiceBox; //导入方法依赖的package包/类
private static ChoiceBox<EyeTracker> buildEyeTrackerConfigChooser(Configuration configuration,
        ConfigurationContext configurationContext) {
    ChoiceBox<EyeTracker> choiceBox = new ChoiceBox<>();

    choiceBox.getItems().addAll(EyeTracker.values());

    EyeTracker selectedEyeTracker = findSelectedEyeTracker(configuration);
    choiceBox.getSelectionModel().select(selectedEyeTracker);

    choiceBox.setPrefWidth(prefWidth);
    choiceBox.setPrefHeight(prefHeight);

    choiceBox.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<EyeTracker>() {
        @Override
        public void changed(ObservableValue<? extends EyeTracker> observable, EyeTracker oldValue,
                EyeTracker newValue) {
            final String newPropertyValue = newValue.name();
            ConfigurationBuilder.createFromPropertiesResource().withEyeTracker(newPropertyValue)
                    .saveConfigIgnoringExceptions();
        }
    });

    return choiceBox;
}
 
开发者ID:schwabdidier,项目名称:GazePlay,代码行数:25,代码来源:ConfigurationContext.java

示例2: createParkingNumberChoiceBox

import javafx.scene.control.ChoiceBox; //导入方法依赖的package包/类
private ChoiceBox<Parking> createParkingNumberChoiceBox() {
    ChoiceBox<Parking> parkingNumberChoiceBox = new ChoiceBox<>();
    parkingNumberChoiceBox.setPrefWidth(150);

    parkingNumberChoiceBox.setConverter(new StringConverter<Parking>() {
        @Override
        public String toString(Parking object) {
            return "(" + object.getId() + ") " + object.getName();
        }

        @Override
        public Parking fromString(String string) {
            Integer id = Integer.valueOf(string.substring(1, string.indexOf(')')));

            try {
                return ParkingApplicationManager.getInstance().getParkingById(id);
            } catch (ParkingNotPresentException e) {
                new Alert(Alert.AlertType.ERROR, "Vous avez sélectionné un parking inexistant. \n" + e);
            }
            return null;
        }
    });

    return parkingNumberChoiceBox;
}
 
开发者ID:SKNZ,项目名称:LesPatternsDuSwag,代码行数:26,代码来源:ChangeParkingStage.java

示例3: buildFixLengthChooserMenu

import javafx.scene.control.ChoiceBox; //导入方法依赖的package包/类
private static ChoiceBox<Double> buildFixLengthChooserMenu(Configuration configuration,
        ConfigurationContext configurationContext) {

    ChoiceBox<Double> choiceBox = new ChoiceBox<>();

    int i = 300;

    choiceBox.getItems().add((double) configuration.getFixationlength() / 1000);
    while (i <= 30000) {

        choiceBox.getItems().add(((double) i) / 1000);
        i = i + 100;
    }

    choiceBox.getSelectionModel().select(0);
    choiceBox.setPrefWidth(prefWidth);
    choiceBox.setPrefHeight(prefHeight);

    choiceBox.getSelectionModel().selectedIndexProperty().addListener(new ChangeListener<Number>() {
        @Override
        public void changed(ObservableValue<? extends Number> observable, Number oldValue, Number newValue) {

            final int newPropertyValue = (int) (1000
                    * (double) choiceBox.getItems().get(Integer.parseInt(newValue.intValue() + "")));

            ConfigurationBuilder.createFromPropertiesResource().withFixationLength(newPropertyValue)
                    .saveConfigIgnoringExceptions();

        }
    });

    return choiceBox;
}
 
开发者ID:schwabdidier,项目名称:GazePlay,代码行数:34,代码来源:ConfigurationContext.java

示例4: buildQuestionLengthChooserMenu

import javafx.scene.control.ChoiceBox; //导入方法依赖的package包/类
private static ChoiceBox<Double> buildQuestionLengthChooserMenu(Configuration configuration,
        ConfigurationContext configurationContext) {

    ChoiceBox<Double> choiceBox = new ChoiceBox<>();

    int i = 500;

    choiceBox.getItems().add((double) configuration.getQuestionLength() / 1000);
    while (i <= 20000) {

        choiceBox.getItems().add(((double) i) / 1000);
        i = i + 500;
    }

    choiceBox.getSelectionModel().select(0);
    choiceBox.setPrefWidth(prefWidth);
    choiceBox.setPrefHeight(prefHeight);

    choiceBox.getSelectionModel().selectedIndexProperty().addListener(new ChangeListener<Number>() {
        @Override
        public void changed(ObservableValue<? extends Number> observable, Number oldValue, Number newValue) {

            final int newPropertyValue = (int) (1000
                    * (double) choiceBox.getItems().get(Integer.parseInt(newValue.intValue() + "")));

            ConfigurationBuilder.createFromPropertiesResource().withQuestionLength(newPropertyValue)
                    .saveConfigIgnoringExceptions();

        }
    });

    return choiceBox;
}
 
开发者ID:schwabdidier,项目名称:GazePlay,代码行数:34,代码来源:ConfigurationContext.java

示例5: buildLanguageChooser

import javafx.scene.control.ChoiceBox; //导入方法依赖的package包/类
private static ChoiceBox<Languages> buildLanguageChooser(Configuration configuration,
        ConfigurationContext configurationContext) {
    Languages currentLanguage = null;
    if (configuration.getLanguage() != null) {
        currentLanguage = Languages.valueOf(configuration.getLanguage());
    }

    ChoiceBox<Languages> choiceBox = new ChoiceBox<>();
    choiceBox.getItems().addAll(Languages.values());
    choiceBox.getSelectionModel().select(currentLanguage);

    choiceBox.setPrefWidth(prefWidth);
    choiceBox.setPrefHeight(prefHeight);

    choiceBox.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<Languages>() {
        @Override
        public void changed(ObservableValue<? extends Languages> observable, Languages oldValue,
                Languages newValue) {

            ConfigurationBuilder.createFromPropertiesResource().withLanguage(newValue.name())
                    .saveConfigIgnoringExceptions();

            configurationContext.getGazePlay().getHomeMenuScreen().onLanguageChanged();

            GridPane gridPane = buildConfigGridPane(configurationContext);
            configurationContext.getRoot().setCenter(null);
            configurationContext.getRoot().setCenter(gridPane);
        }
    });

    return choiceBox;
}
 
开发者ID:schwabdidier,项目名称:GazePlay,代码行数:33,代码来源:ConfigurationContext.java

示例6: ifLhs

import javafx.scene.control.ChoiceBox; //导入方法依赖的package包/类
public void ifLhs() {
	if (ourOpen instanceof MainController) {
		final ChoiceBox<String> searchParams = new ChoiceBox<String>();

		searchParams.setOnAction(new EventHandler<ActionEvent>() {
            public void handle(ActionEvent event) {
                if (((String) searchParams.getValue()).equals("Real Entities")) {
                	setEntitiesToSearch(EntitiesToSearch.ALL);
                } else if (((String) searchParams.getValue()).equals("NPCs")) {
                	setEntitiesToSearch(EntitiesToSearch.NPC);
                } else if (((String) searchParams.getValue()).equals("Gods")) {
                	setEntitiesToSearch(EntitiesToSearch.GOD);
                } else if (((String) searchParams.getValue()).equals("Regions")) {
                	setEntitiesToSearch(EntitiesToSearch.REGION);
                } else if (((String) searchParams.getValue()).equals("Groups")) {
                	setEntitiesToSearch(EntitiesToSearch.EVENT);
                } else if (((String) searchParams.getValue()).equals("Templates")) {
                	setEntitiesToSearch(EntitiesToSearch.TEMPLATE);
                } else if (((String) searchParams.getValue()).equals("Statblocks")) {
                	setEntitiesToSearch(EntitiesToSearch.STATBLOCK);
                }
                searchDB();
            }
        });
		
		searchParams.getItems().add("Real Entities");
		searchParams.getItems().add("NPCs");
		searchParams.getItems().add("Gods");
		searchParams.getItems().add("Regions");
		searchParams.getItems().add("Groups");
		searchParams.getItems().add("Templates");
		searchParams.getItems().add("Statblocks");
		
		searchParams.setPrefWidth(vbox.getPrefWidth());
		
		// cancerous way to reorder the nodes to put search option between search bar and results
		// NO JAY DON'T LOOK
		
		List<Node> l = new ArrayList<Node>();
		l.add(vbox.getChildren().get(0));
		l.add(searchParams);
		l.add(vbox.getChildren().get(1));
		
		vbox.getChildren().setAll(l);
		l = null;
		
		searchParams.getSelectionModel().select(0);
		
		clearList();
		
	}
}
 
开发者ID:ForJ-Latech,项目名称:fwm,代码行数:53,代码来源:SearchList.java

示例7: HTMLEditorSample

import javafx.scene.control.ChoiceBox; //导入方法依赖的package包/类
public HTMLEditorSample() {
    final VBox root = new VBox();
    root.setPadding(new Insets(8, 8, 8, 8));
    root.setSpacing(5);
    root.setAlignment(Pos.BOTTOM_LEFT);

    final GridPane grid = new GridPane();
    grid.setVgap(5);
    grid.setHgap(10);

    final ChoiceBox sendTo = new ChoiceBox(FXCollections.observableArrayList("To:", "Cc:", "Bcc:"));

    sendTo.setPrefWidth(100);
    GridPane.setConstraints(sendTo, 0, 0);
    grid.getChildren().add(sendTo);

    final TextField tbTo = new TextField();
    tbTo.setPrefWidth(400);
    GridPane.setConstraints(tbTo, 1, 0);
    grid.getChildren().add(tbTo);

    final Label subjectLabel = new Label("Subject:");
    GridPane.setConstraints(subjectLabel, 0, 1);
    grid.getChildren().add(subjectLabel);

    final TextField tbSubject = new TextField();
    tbTo.setPrefWidth(400);
    GridPane.setConstraints(tbSubject, 1, 1);
    grid.getChildren().add(tbSubject);

    root.getChildren().add(grid);

    Platform.runLater(() -> {
        final HTMLEditor htmlEditor = new HTMLEditor();
        htmlEditor.setPrefHeight(370);
        root.getChildren().addAll(htmlEditor, new Button("Send"));
    });

    final Label htmlLabel = new Label();
    htmlLabel.setWrapText(true);
    getChildren().add(root);
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:43,代码来源:HTMLEditorSample.java

示例8: buildStyleThemeChooser

import javafx.scene.control.ChoiceBox; //导入方法依赖的package包/类
/**
 * Fonction to use to permit to user to select between several theme
 */
private static ChoiceBox<Themes> buildStyleThemeChooser(Configuration configuration,
        ConfigurationContext configurationContext) {
    ChoiceBox<Themes> themesBox = new ChoiceBox<>();
    Themes[] TThemes = Themes.values();

    int firstPos = 1;

    for (int i = 0; i < TThemes.length; i++) {
        themesBox.getItems().add(TThemes[i]);
    }
    final String cssfile = configuration.getCssfile();

    if (cssfile.indexOf("orange") > 0) {
        themesBox.getSelectionModel().select(0);
    } else if (cssfile.indexOf("green") > 0) {
        themesBox.getSelectionModel().select(1);
    } else if (cssfile.indexOf("light-blue") > 0) {
        themesBox.getSelectionModel().select(2);
    } else
        themesBox.getSelectionModel().select(3);
    themesBox.setPrefWidth(prefWidth);
    themesBox.setPrefHeight(prefHeight);

    themesBox.getSelectionModel().selectedIndexProperty().addListener(new ChangeListener<Number>() {
        @Override
        public void changed(ObservableValue<? extends Number> observable, Number oldValue, Number newValue) {
            log.info(newValue + "");

            String newPropertyValue;

            if (TThemes[newValue.intValue()].toString().equals("green"))
                newPropertyValue = "data/stylesheets/main-green.css";
            else if (TThemes[newValue.intValue()].toString().equals("blue"))
                newPropertyValue = "data/stylesheets/main-blue.css";
            else if (TThemes[newValue.intValue()].toString().equals("light_blue"))
                newPropertyValue = "data/stylesheets/main-light-blue.css";
            else
                newPropertyValue = "data/stylesheets/main-orange.css";

            ConfigurationBuilder.createFromPropertiesResource().withCssFile(newPropertyValue)
                    .saveConfigIgnoringExceptions();

            Scene scene = configurationContext.getScene();

            scene.getStylesheets().remove(0);
            scene.getStylesheets().add(newPropertyValue);

            log.info(scene.getStylesheets().toString());
        }
    });

    return themesBox;
}
 
开发者ID:schwabdidier,项目名称:GazePlay,代码行数:57,代码来源:ConfigurationContext.java

示例9: drawPlayersSettings

import javafx.scene.control.ChoiceBox; //导入方法依赖的package包/类
/**
 * Affiche les réglages concernant le nombre de joueurs
 */
private void drawPlayersSettings() {
  GridPane playersSettingsGrid = new GridPane();
  
  ColumnConstraints column1 = new ColumnConstraints(150);
  ColumnConstraints column2 = new ColumnConstraints(200);
  
  playersSettingsGrid.getColumnConstraints().setAll(column1, column2);
  
  /**
   * Choix du nombre de joueurs
   */
  Label nbOfPlayersLabel = new Label("Nombre de joueurs :");
  playersSettingsGrid.add(nbOfPlayersLabel, 0, 0);
  
  ChoiceBox<Integer> nbOfPlayersChoiceBox = new ChoiceBox<Integer>();
  nbOfPlayersChoiceBox.setPrefWidth(200);
  
  nbOfPlayersChoiceBox.setItems(
      FXCollections.observableArrayList(
          2,
          3,
          4
      )
  );
  
  nbOfPlayersChoiceBox.getSelectionModel().selectedIndexProperty().addListener(new ChangeListener<Number>() {
    @Override
    public void changed(ObservableValue<? extends Number> observableValue, Number oldValue, Number newValue) {
      nbOfPlayers = nbOfPlayersChoiceBox.getItems().get((Integer) newValue);
      drawPlayersList();
    }
  });
  
  // Valeur par défaut
  nbOfPlayersChoiceBox.setValue(2);
  nbOfPlayers = 2;
  
  GridPane.setMargin(nbOfPlayersChoiceBox, new Insets(5, 0, 5, 0));
  
  playersSettingsGrid.add(nbOfPlayersChoiceBox, 1, 0);
  
  playersSettingsGrid.add(playersList, 0, 1, 2, 1);
  
  root.add(playersSettingsGrid, 0, currentIndex++);
  
  Separator playersSettingsSeparator = new Separator();
  root.add(playersSettingsSeparator, 0, currentIndex++);
  
  GridPane.setMargin(playersSettingsSeparator, new Insets(5, 0, 5, 0));
}
 
开发者ID:ThibaultVlacich,项目名称:Jeu-des-6-couleurs,代码行数:54,代码来源:NewGameWindow.java

示例10: getChoice

import javafx.scene.control.ChoiceBox; //导入方法依赖的package包/类
private ChoiceBox<ControlsFactory> getChoice() {
    ChoiceBox<ControlsFactory> cb = new ChoiceBox();
    cb.getItems().addAll(getControlsSet());
    cb.setPrefWidth(200);
    return cb;
}
 
开发者ID:teamfx,项目名称:openjfx-8u-dev-tests,代码行数:7,代码来源:AddRowColumnApp.java

示例11: start

import javafx.scene.control.ChoiceBox; //导入方法依赖的package包/类
@Override
public void start(Stage primaryStage) {


    final TextArea testText = TextAreaBuilder.create()
            .text("Test")
            .prefHeight(50)
            .prefWidth(500)
            .build();

    final ChoiceBox<Interpolator> interpolatorChoiceBox = new ChoiceBox<Interpolator>();
    interpolatorChoiceBox.getItems().addAll(FXCollections.observableArrayList(
                Interpolator.LINEAR,
                Interpolator.DISCRETE,
                Interpolator.EASE_BOTH,
                Interpolator.EASE_IN,
                Interpolator.EASE_OUT
                ));
    interpolatorChoiceBox.setPrefHeight(25);
    interpolatorChoiceBox.setPrefWidth(500);

    interpolatorChoiceBox.getSelectionModel().selectFirst();


    final Text lcdText = TextBuilder.create()
            .x(100)
            .y(100)
            .fontSmoothingType(FontSmoothingType.LCD)
            .build();

    lcdText.textProperty().bind(testText.textProperty());

    final Circle point = CircleBuilder.create()
            .centerX(100)
            .centerY(100)
            .radius(2)
            .fill(Color.RED)
            .build();

    Pane root = VBoxBuilder.create()
            .children(
                PaneBuilder.create()
                .minWidth(500)
                .minHeight(500)
                .children(
                    lcdText,
                    point)
                .onMouseClicked(new EventHandler<MouseEvent>() {

                    @Override
                    public void handle(MouseEvent event) {
                        point.setCenterX(event.getX());
                        point.setCenterY(event.getY());

                        TimelineBuilder.create()
                            .keyFrames(
                                new KeyFrame(Duration.seconds(5),
                                    new KeyValue(lcdText.xProperty(), event.getX(),
                                        interpolatorChoiceBox.getSelectionModel().getSelectedItem())),
                                new KeyFrame(Duration.seconds(5),
                                    new KeyValue(lcdText.yProperty(), event.getY(),
                                        interpolatorChoiceBox.getSelectionModel().getSelectedItem()))
                                )
                            .build()
                            .play();
                    }
                })
                .build(),
                testText,
                interpolatorChoiceBox)
            .build();



    Scene scene = new Scene(root, 500, 575);

    primaryStage.setTitle("Test Animnation LCD Text");
    primaryStage.setResizable(false);
    primaryStage.setScene(scene);
    primaryStage.show();
}
 
开发者ID:teamfx,项目名称:openjfx-8u-dev-tests,代码行数:82,代码来源:AnimationLCDTextTestApp.java


注:本文中的javafx.scene.control.ChoiceBox.setPrefWidth方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。