本文整理汇总了Java中javafx.scene.web.WebView.setMinWidth方法的典型用法代码示例。如果您正苦于以下问题:Java WebView.setMinWidth方法的具体用法?Java WebView.setMinWidth怎么用?Java WebView.setMinWidth使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javafx.scene.web.WebView
的用法示例。
在下文中一共展示了WebView.setMinWidth方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: start
import javafx.scene.web.WebView; //导入方法依赖的package包/类
public void start(Stage stage){
WebView view = new WebView();
WebEngine e = view.getEngine();
e.loadContent("<div style='width: 50px; background-color: limegreen;'>Narrow div</div>");
view.setMinWidth(MIN_WIDTH);
view.setId(VIEW_ID);
HBox box = new HBox();
box.setMaxWidth(MIN_WIDTH - 10);
box.setMinWidth(MIN_WIDTH - 10);
box.setPrefWidth(MIN_WIDTH - 10);
box.getChildren().add(view);
final Scene scene = new Scene(box);
stage.setTitle(VIEW_ID);
stage.setScene(scene);
stage.sizeToScene();
stage.show();
System.out.println(view.getWidth());
}
示例2: createSimpleWFS
import javafx.scene.web.WebView; //导入方法依赖的package包/类
private void createSimpleWFS(
WFSMeta.StoredQuery type,
VBox container,
List <OutputFormatModel> outputFormats
) {
container.getChildren().clear();
Label descriptionHead = new Label();
descriptionHead.setText(I18n.getMsg("gui.description"));
Font font = descriptionHead.getFont();
descriptionHead.setFont(
Font.font(font.getFamily(),
FontWeight.BOLD,
FONT_BIG));
WebView description = new WebView();
description.setFontScale(FONTSCALE);
description.setPrefHeight(WEBVIEW_PREF_HEIGHT);
description.setPrefWidth(WEBVIEW_PREF_WIDTH);
description.setMinHeight(WEBVIEW_MIN_HEIGHT);
description.setMinWidth(WEBVIEW_MIN_WIDTH);
WebEngine engine = description.getEngine();
java.lang.reflect.Field f;
try {
f = engine.getClass().getDeclaredField("page");
f.setAccessible(true);
com.sun.webkit.WebPage page =
(com.sun.webkit.WebPage) f.get(engine);
page.setBackgroundColor(
(new java.awt.Color(BGCOLOR, BGCOLOR, BGCOLOR)).getRGB());
} catch (NoSuchFieldException
| SecurityException
| IllegalArgumentException
| IllegalAccessException e) {
// Displays the webview with white background...
}
engine.loadContent(type.getAbstractDescription());
container.getChildren().add(descriptionHead);
container.getChildren().add(description);
container.setMargin(descriptionHead,
new Insets(MARGIN_5, MARGIN_5, MARGIN_5, MARGIN_5));
container.setMargin(description,
new Insets(MARGIN_5, MARGIN_5, MARGIN_5, MARGIN_15));
for (Field entry : type.getParameters()) {
HBox attributeItem = createAttributeItem(entry);
container.getChildren().add(attributeItem);
}
Separator sep = new Separator();
HBox outputFormatBox = new HBox();
Label outputFormatLabel = new Label();
outputFormatLabel.setText(I18n.format("gui.data-format"));
ComboBox outputFormat = new ComboBox();
outputFormat.setId(DATAFORMAT_ID);
ObservableList<OutputFormatModel> out =
FXCollections.observableArrayList();
out.addAll(outputFormats);
outputFormat.setItems(out);
outputFormatLabel.setLabelFor(outputFormat);
outputFormatLabel.setPrefWidth(OUTPUTFORMAT_PREF_WIDTH);
outputFormatBox.getChildren().add(outputFormatLabel);
outputFormatBox.getChildren().add(outputFormat);
outputFormatBox.setMargin(outputFormatLabel,
new Insets(MARGIN_5, MARGIN_5, MARGIN_5, MARGIN_15));
outputFormatBox.setMargin(outputFormatLabel,
new Insets(MARGIN_5, MARGIN_5, MARGIN_5, MARGIN_15));
container.getChildren().add(sep);
container.getChildren().add(outputFormatBox);
}