本文整理匯總了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);
}
示例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();
}
});
}
示例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));
}