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


Java ComboBox.setPrefWidth方法代码示例

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


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

示例1: createDisplayOptionsRow

import javafx.scene.control.ComboBox; //导入方法依赖的package包/类
private Pair<Node, ComboBox<String>> createDisplayOptionsRow()
{
	BorderPane rowDisplay = new BorderPane();
	
	Label label = new Label("Display values as: ");
	rowDisplay.setLeft(label);
	
	ComboBox<String> dropdown = createDisplayOptionsDropdown();
	dropdown.setPrefWidth(Integer.MAX_VALUE);
	rowDisplay.setCenter(dropdown);
	
	return new Pair<>(rowDisplay, dropdown);
}
 
开发者ID:dhawal9035,项目名称:WebPLP,代码行数:14,代码来源:WatcherWindow.java

示例2: handleAddItem

import javafx.scene.control.ComboBox; //导入方法依赖的package包/类
public void handleAddItem(ActionEvent actionEvent) {
    ChoiceDialog<ChoiceEntry> dialog = new ChoiceDialog<>(null, item_registry);
    dialog.setTitle("Přidat item");
    dialog.setHeaderText("Výběr itemu");
    dialog.setContentText("Vyberte...");
    // Trocha čarování k získání reference na combobox abych ho mohl upravit
    final ComboBox<ChoiceEntry> comboBox = (ComboBox) (((GridPane) dialog.getDialogPane()
        .getContent())
        .getChildren().get(1));
    comboBox.setPrefWidth(100);
    comboBox.setButtonCell(new ChoiceEntryCell());
    comboBox.setCellFactory(param -> new ChoiceEntryCell());
    comboBox.setMinWidth(200);
    comboBox.setMinHeight(40);
    Optional<ChoiceEntry> result = dialog.showAndWait();
    result.ifPresent(choiceEntry -> {
        try {
            final Optional<ItemEntry> entry = items.stream()
                .filter(itemEntry -> itemEntry.getId().equals(choiceEntry.id.get()))
                .findFirst();
            if (!entry.isPresent()) {
                items.add(new ItemEntry(choiceEntry));
            }
        } catch (ItemException e) {
            e.printStackTrace();
        }
    });
}
 
开发者ID:stechy1,项目名称:drd,代码行数:29,代码来源:HeroCreatorController3.java

示例3: loadPropertyCreator

import javafx.scene.control.ComboBox; //导入方法依赖的package包/类
private void loadPropertyCreator(){
	nameField = new TextField();
	nameField.setPrefWidth(150);
	valField = new TextField();
	valField.setPrefWidth(150);
	valField.setDisable(true);
	final ComboBox<Property.Type> typeBox = new ComboBox<Property.Type>();
	typeBox.setPrefWidth(150);
	typeBox.getItems().addAll(Property.Type.values());
	final Button save = new Button("Save"), cancel = new Button("Cancel");
	save.setDisable(true);
	
	nameField.textProperty().addListener((observable, oldValue, newValue)->{
		if(valField.isDisabled() && !newValue.equals(""))
			valField.setDisable(false);
	});
	valField.textProperty().addListener((observable, oldValue, newValue)->{
		if(!valField.getText().equals(""))
			save.setDisable(false);
		else save.setDisable(true);
	});
	
	save.setOnAction((e)->{
		String newVal = valField.getText();
		String keyName = nameField.getText();
		Property.Type t = typeBox.getValue();
		System.out.println(t);
		System.out.println(newVal);
		
		cProp = new Property(keyName, t);
		if(!newProp(cProp, newVal))
			FlashFXUtils.showErrorDialog(this, "Error", "Value is incompatible with property type");
		else close();
	});
	cancel.setOnAction((e)->{
		cProp = null;
		close();
	});
	
	VBox viewerNode = new VBox();
	viewerNode.getChildren().addAll(nameField, valField, typeBox);
	viewerNode.setSpacing(10);
	viewerNode.setAlignment(Pos.CENTER);
	viewerNode.setPadding(new Insets(10, 10, 10, 10));
	HBox buttonNode = new HBox();
	buttonNode.getChildren().addAll(save, cancel);
	buttonNode.setSpacing(10);
	buttonNode.setAlignment(Pos.CENTER_RIGHT);
	buttonNode.setPadding(new Insets(0, 5, 5, 0));
	BorderPane pane = new BorderPane();
	pane.setBottom(buttonNode);
	pane.setCenter(viewerNode);
	setScene(new Scene(pane, 200, 200));
}
 
开发者ID:Flash3388,项目名称:FlashLib,代码行数:55,代码来源:PropertyViewer.java


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