本文整理汇总了Java中javafx.scene.control.ComboBox.setMinWidth方法的典型用法代码示例。如果您正苦于以下问题:Java ComboBox.setMinWidth方法的具体用法?Java ComboBox.setMinWidth怎么用?Java ComboBox.setMinWidth使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javafx.scene.control.ComboBox
的用法示例。
在下文中一共展示了ComboBox.setMinWidth方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createControlPane
import javafx.scene.control.ComboBox; //导入方法依赖的package包/类
private HBox createControlPane()
{
HBox hbox = new HBox();
setAlignment(hbox, Pos.CENTER);
hbox.setAlignment(Pos.CENTER_LEFT);
hbox.setPadding(new Insets(10, 10, 10, 10));
hbox.setSpacing(5);
Label label = new Label("Send");
label.setMinWidth(Label.USE_PREF_SIZE);
hbox.getChildren().add(label);
ComboBox<String> dropdown = createDisplayOptionsDropdown();
dropdown.setMinWidth(ComboBox.USE_PREF_SIZE);
hbox.getChildren().add(dropdown);
TextField valueField = new TextField();
valueField.setPrefWidth(Integer.MAX_VALUE);
hbox.getChildren().add(valueField);
Button send = new Button("Send");
send.setMinWidth(Button.USE_PREF_SIZE);
hbox.getChildren().add(send);
Button clear = new Button("Clear");
clear.setMinWidth(Button.USE_PREF_SIZE);
clear.setOnAction((event) -> clear());
hbox.getChildren().add(clear);
return hbox;
}
示例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: addSpecialInstrumentationItem
import javafx.scene.control.ComboBox; //导入方法依赖的package包/类
public static void addSpecialInstrumentationItem(int id, KeyValuePair sectionType, KeyValuePair specialInstrumentation, int specialInstrumentationCount,
List<SpecialInstrumentationEntity> specialInstrumentationEntityList, GridPane specialInstrumentationContent,
ComboBox<KeyValuePair> specialInstrumentationSectionGroupComboBox, NumberField specialInstrumentationNumberField) {
GridPane tmpPane = new GridPane();
ComboBox<KeyValuePair> sectionTypeComboBox = new ComboBox<>(specialInstrumentationSectionGroupComboBox.getItems());
sectionTypeComboBox.getSelectionModel().select(sectionType);
sectionTypeComboBox.setMaxWidth(100);
sectionTypeComboBox.setMinWidth(100);
tmpPane.addColumn(0, sectionTypeComboBox);
ComboBox<KeyValuePair> specialInstrumentationComboBox = new ComboBox<>(TeamF.client.helper.gui.InstrumentationHelper.getInstrumentTypes((SectionGroupType) sectionTypeComboBox.getSelectionModel().getSelectedItem().getValue()));
specialInstrumentationComboBox.getSelectionModel().selectFirst();
specialInstrumentationComboBox.setMaxWidth(100);
specialInstrumentationComboBox.setMinWidth(100);
tmpPane.addColumn(1, specialInstrumentationComboBox);
NumberField tmpNumberField = null;
try {
tmpNumberField = new NumberField(specialInstrumentationCount, specialInstrumentationNumberField.getMinValue().intValue(), specialInstrumentationNumberField.getMaxValue().intValue());
tmpPane.addColumn(2, tmpNumberField);
tmpNumberField.setMaxWidth(60);
tmpNumberField.setStyle("-fx-opacity: 1");
} catch (NumberRangeException e) {
}
sectionTypeComboBox.getSelectionModel().selectedItemProperty().addListener((observable, oldValue, newValue) -> {
if (newValue != null) {
if(((TeamF.client.helper.gui.InstrumentationHelper.getInstrumentTypes((SectionGroupType) sectionTypeComboBox.getSelectionModel().
getSelectedItem().getValue())))!=null) {
specialInstrumentationComboBox.setItems((TeamF.client.helper.gui.InstrumentationHelper.getInstrumentTypes((SectionGroupType) sectionTypeComboBox.getSelectionModel().
getSelectedItem().getValue())));
specialInstrumentationComboBox.getSelectionModel().selectFirst();
}
}
});
Button tmpButton = new Button("-");
tmpPane.addColumn(3, tmpButton);
specialInstrumentationContent.addRow(specialInstrumentationEntityList.size()+1, tmpPane);
specialInstrumentationContent.setColumnSpan(tmpPane, 4);
SpecialInstrumentationEntity specialInstrumentationEntity = new SpecialInstrumentationEntity(id, sectionTypeComboBox, specialInstrumentationComboBox, tmpNumberField, tmpPane);
tmpButton.setOnAction(e -> removeSpecialInstrumentationItem(specialInstrumentationEntity, specialInstrumentationContent, specialInstrumentationEntityList));
specialInstrumentationEntityList.add(specialInstrumentationEntity);
}