本文整理汇总了Java中javafx.scene.layout.Region.setMinWidth方法的典型用法代码示例。如果您正苦于以下问题:Java Region.setMinWidth方法的具体用法?Java Region.setMinWidth怎么用?Java Region.setMinWidth使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javafx.scene.layout.Region
的用法示例。
在下文中一共展示了Region.setMinWidth方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createUi
import javafx.scene.layout.Region; //导入方法依赖的package包/类
private void createUi() {
getStyleClass().add(TITLE_BAR_STYLE_CLASS);
setAlignment(Pos.CENTER_RIGHT);
setMaxWidth(Double.MAX_VALUE);
Region selectedBar = new Region();
selectedBar.getStyleClass().add(HIGHLIGHT_STYLE_CLASS);
selectedBar.setMinWidth(Region.USE_PREF_SIZE);
selectedBar.setMaxHeight(Region.USE_PREF_SIZE);
selectedBar.setMaxWidth(Double.MAX_VALUE);
StackPane.setAlignment(selectedBar, Pos.BOTTOM_CENTER);
StackPane labelPane = new StackPane(label, selectedBar);
labelPane.setMaxHeight(Double.MAX_VALUE);
labelPane.setMaxWidth(Region.USE_PREF_SIZE);
Region filler = new Region();
HBox.setHgrow(filler, Priority.ALWAYS);
rightLabel.getStyleClass().setAll(RIGHT_LABEL_STYLE_CLASS);
new FadeInAnimator().apply(expanded, selectedBar);
new FadeInAnimator().apply(expanded, rightLabel);
getChildren().addAll(labelPane, filler, rightLabel);
}
示例2: populateMenu
import javafx.scene.layout.Region; //导入方法依赖的package包/类
private void populateMenu(Map<DocumentType, List<SearchResult>> results) {
contextMenu.getItems().clear();
for (Map.Entry<DocumentType, List<SearchResult>> entry : results.entrySet()) {
boolean first = true;
for(SearchResult result: entry.getValue()) {
final SearchResult sr = result;
final HBox hBox = new HBox();
hBox.setFillHeight(true);
Label itemLabel = new Label(result.getName());
itemLabel.getStyleClass().add("item-label");
if (first) {
first = false;
Label groupLabel = new Label(result.getDocumentType().getPluralDisplayName());
groupLabel.getStyleClass().add("group-label");
groupLabel.setAlignment(Pos.CENTER_RIGHT);
groupLabel.setMinWidth(USE_PREF_SIZE);
groupLabel.setPrefWidth(70);
hBox.getChildren().addAll(groupLabel,itemLabel);
} else {
Region spacer = new Region();
spacer.setMinWidth(USE_PREF_SIZE);
spacer.setPrefWidth(70);
hBox.getChildren().addAll(spacer,itemLabel);
}
// create a special node for hiding/showing popup content
final Region popRegion = new Region();
popRegion.getStyleClass().add("search-menu-item-popup-region");
popRegion.setPrefSize(10, 10);
hBox.getChildren().add(popRegion);
final String name = (result.getDocumentType() == DocumentType.SAMPLE) ? result.getName() :
result.getPackageName()+
((result.getClassName() != null) ? "."+result.getClassName() : "") +
((result.getName() != null) ? "."+result.getName() : "");
final String shortDescription = (result.getShortDescription().length() == 160) ? result.getShortDescription() +"..." : result.getShortDescription();
popRegion.opacityProperty().addListener(new ChangeListener<Number>() {
@Override public void changed(ObservableValue<? extends Number> observable, Number oldValue, Number newValue) {
Platform.runLater( new Runnable() { // TODO runLater used here as a workaround for RT-14396
@Override public void run() {
if (popRegion.getOpacity() == 1) {
infoName.setText(name);
infoDescription.setText(shortDescription);
Point2D hBoxPos = hBox.localToScene(0, 0);
extraInfoPopup.show(getScene().getWindow(),
hBoxPos.getX() + contextMenu.getScene().getX() + contextMenu.getX() - infoBox.getPrefWidth() - 10,
hBoxPos.getY() + contextMenu.getScene().getY() + contextMenu.getY() - 27
);
}
}
});
}
});
// create menu item
CustomMenuItem menuItem = new CustomMenuItem(hBox, true);
menuItem.getStyleClass().add("search-menu-item");
contextMenu.getItems().add(menuItem);
// handle item selection
menuItem.setOnAction(new EventHandler<ActionEvent>() {
@Override public void handle(ActionEvent actionEvent) {
///System.out.println("SearchBox.handle menuItem.setOnAction");
Ensemble2.getEnsemble2().goToPage(sr.getEnsemblePath(),true);
}
});
}
}
}