下面列出了javafx.scene.control.Label#setMaxHeight ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
private Label createExtentLabel() {
final Label newLabel = new Label();
// Align the text vertically:
newLabel.setRotate(270d);
// Fix the dimensions to prevent jittery motion on value changes:
newLabel.setMinWidth(150d);
newLabel.setPrefWidth(150d);
newLabel.setMaxWidth(150d);
newLabel.setMinHeight(30d);
newLabel.setPrefHeight(30d);
newLabel.setMaxHeight(30d);
newLabel.setAlignment(Pos.CENTER);
return newLabel;
}
private Tab getTab(Supplier<String> getter, Consumer<String> setter, String title) {
ContentEditor postEditor = new ContentEditor();
postEditor.setEditable(true);
postEditor.setContent(getter, setter);
postEditor.setContentTypePlugins(Collections.singletonList(new JavascriptContentType()));
postEditor.setContentType("application/javascript");
postEditor.setHeaderVisibility(false);
Tab postTab = new Tab("", postEditor);
Label label = new Label(title);
label.setRotate(90);
label.setMinWidth(150);
label.setMaxWidth(150);
label.setMinHeight(40);
label.setMaxHeight(40);
label.setPadding(new Insets(0));
postTab.setGraphic(label);
return postTab;
}
public void showAndWait(List<OptionPageProvider> optionPageProviders) {
JFXDialogLayout content = new OptionsDialogFxml(this);
content.setPrefWidth(600);
for(OptionPageProvider<?> p : optionPageProviders) {
OptionDialogPane pane = p.getOptionsDialog(new OptionDialogBuilder());
Tab tab = new Tab("", pane);
Label label = new Label(pane.getName());
label.setRotate(90);
label.setMinWidth(100);
label.setMaxWidth(100);
label.setMinHeight(40);
label.setMaxHeight(40);
tab.setGraphic(label);
tabs.getTabs().add(tab);
}
dialog = FxmlUtil.createDialog(content);
dialog.showAndWait();
}
/**
* Create a new status panel.
* <p/>
* @param group the group this panel is part of.
* @param labelText the text to put on the label on this panel.
* @param index the index of this panel on the group.
*/
StatusPanel(StatusPanelGroup group, String labelText, int index) {
setAlignment(Pos.CENTER);
setSpacing(5);
this.group = group;
this.index = index;
label = new Label(labelText);
label.setAlignment(Pos.CENTER);
label.setMaxHeight(Double.MAX_VALUE);
HBox.setMargin(label, new Insets(5));
progressBar = new ProgressBar();
progressBar.setMaxWidth(Double.MAX_VALUE); //Allow progress bar to fill space.
HBox.setHgrow(progressBar, Priority.ALWAYS);
cancelButton = new Button("", new ImageView(new Image("file:icons/cross.png", 13, 13, false, true)));
Utils.setToolbarButtonStyle(cancelButton);
cancelButton.setAlignment(Pos.CENTER);
getChildren().add(label);
getChildren().add(progressBar);
getChildren().add(cancelButton);
}
public static Toast makeText(String text, boolean wrapText, double maxWidth, double maxHeight, Duration duration) {
Label label = new Label(text);
label.getStyleClass().add("text");
label.setWrapText(wrapText);
label.setMaxWidth(maxWidth);
label.setMaxHeight(maxHeight);
label.setTextFill(DEFAULT_FILL_COLOR);
return makeToast(label, duration);
}
private void updateText() {
textBox.getChildren().clear();
for (int i = 0; i <= 2; i++) {
Label label = new Label(textProperty.get(i));
label.setWrapText(true);
label.setMaxHeight(Double.MAX_VALUE);
label.setAlignment(Pos.TOP_LEFT);
if (i == 0) {
label.getStyleClass().add("primary");
}
textBox.getChildren().add(label);
VBox.setVgrow(label, Priority.ALWAYS);
}
}
@Override
public Node apply(int paragraphIndex) {
int lineNo = paragraphIndex + 1;
Val<String> text = lineCount.map(n -> {
int digits = Math.max(3, (int) Math.floor(Math.log10(textArea.getParagraphs().size())) + 1);
return String.format("%" + digits + "d", lineNo);
});
Label label = new Label();
label.textProperty().bind(text.conditionOnShowing(label));
label.setAlignment(Pos.TOP_RIGHT);
label.setMaxHeight(Double.MAX_VALUE);
label.getStyleClass().add("lineno");
return label;
}
public Node create()
{
final Label label = new Label(Messages.PV_Label);
pv_name.setOnAction(event -> setPVName(pv_name.getText()));
pv_name.setTooltip(new Tooltip(Messages.PV_TT));
PVAutocompleteMenu.INSTANCE.attachField(pv_name);
final ToggleButton latch = new ToggleButton(null, getImageView("run.png"));
latch.setTooltip(new Tooltip(Messages.LatchTT));
latch.setOnAction(event ->
{
tree.getModel().latchOnAlarm(latch.isSelected());
if (latch.isSelected())
latch.setGraphic(getImageView("pause_on_alarm.png"));
else
latch.setGraphic(getImageView("run.png"));
});
final Button collapse = new Button(null, getImageView("collapse.gif"));
collapse.setTooltip(new Tooltip(Messages.CollapseTT));
collapse.setOnAction(event -> tree.expandAll(false));
final Button alarms = new Button(null, getImageView("alarmtree.png"));
alarms.setTooltip(new Tooltip(Messages.ExpandAlarmsTT));
alarms.setOnAction(event -> tree.expandAlarms());
final Button expand = new Button(null, getImageView("pvtree.png"));
expand.setTooltip(new Tooltip(Messages.ExpandAllTT));
expand.setOnAction(event -> tree.expandAll(true));
// center vertically
label.setMaxHeight(Double.MAX_VALUE);
HBox.setHgrow(pv_name, Priority.ALWAYS);
final HBox top = new HBox(5, label, pv_name, latch, collapse, alarms, expand);
BorderPane.setMargin(top, new Insets(5, 5, 0, 5));
BorderPane.setMargin(tree.getNode(), new Insets(5));
final BorderPane layout = new BorderPane(tree.getNode());
layout.setTop(top);
hookDragDrop(layout);
return layout;
}
private Node getLabel(String text) {
Label label = new Label(text);
label.setWrapText(true);
label.setMaxHeight(Double.MAX_VALUE);
return label;
}
public TimeIndicator(String pattern) {
l = new Label();
l.setMaxHeight(Double.MAX_VALUE);
l.getStyleClass().add("currenttime");
formatter = DateTimeFormatter.ofPattern(pattern);
}