當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。