下面列出了javafx.scene.layout.AnchorPane#setPrefWidth ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
private Node getGapNode(double value) {
AnchorPane tempPane = new AnchorPane();
tempPane.setPrefWidth(value);
tempPane.setPrefHeight(value);
tempPane.setBackground(Background.EMPTY);
return tempPane;
}
private Node getGapNode(double value) {
AnchorPane tempPane = new AnchorPane();
tempPane.setPrefWidth(value);
tempPane.setPrefHeight(value);
tempPane.setBackground(Background.EMPTY);
return tempPane;
}
public Node getGapNode(double value) {
AnchorPane pane = new AnchorPane();
pane.setPrefWidth(value);
pane.setPrefHeight(value);
pane.setBackground(Background.EMPTY);
return pane;
}
private Node getGapNode(double value) {
AnchorPane tempPane = new AnchorPane();
tempPane.setPrefWidth(value);
tempPane.setPrefHeight(value);
tempPane.setBackground(Background.EMPTY);
return tempPane;
}
private Node getGapNode(double value) {
AnchorPane tempPane = new AnchorPane();
tempPane.setPrefWidth(value);
tempPane.setPrefHeight(value);
tempPane.setBackground(Background.EMPTY);
return tempPane;
}
private Node getGapNode(double value) {
AnchorPane tempPane = new AnchorPane();
tempPane.setPrefWidth(value);
tempPane.setPrefHeight(value);
tempPane.setBackground(Background.EMPTY);
return tempPane;
}
private void init() {
loginButton.setText("点击");
loginButton.setLayoutX(220);
loginButton.setLayoutY(160);
loginButton.setPrefWidth(60);
AnchorPane userPane = new AnchorPane();
userPane.setPrefWidth(240);
userPane.setPrefHeight(180);
userPane.getChildren().addAll(loginButton);
this.setTitle("登录");
this.setWidth(320);
this.setHeight(260);
this.setCenter(userPane);
this.setBackground("Resources\\Images\\Wallpaper\\1.jpg");
loginButton.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
if(mainFrame.isShowing()){
mainFrame.hide();
}else{
mainFrame.show();
}
}
});
}
public void createMapToolBox() {
// Set up the map tool anchor pane
mapToolAnchorPane = new AnchorPane();
mapToolAnchorPane.setId("map-tool-anchor-pane");
//mapToolAnchorPane.setStyle("-fx-background-color: lightgrey; ");
// see https://introjava.wordpress.com/2012/03/23/java-fx-2-linear-gradients/
// mapToolAnchorPane.setStyle(
//// "-fx-background-radius: 15px;"
//// + "-fx-background-color: linear-gradient(lightgrey, darkgrey);"
// //+ "-fx-background-color: darkgrey;"
// "-fx-background-color:"
// + "linear-gradient(#686868 0%, #232723 25%, #373837 75%, #757575 100%),"
// + " linear-gradient(#020b02, #3a3a3a),"
// + " linear-gradient(#9d9e9d 0%, #6b6a6b 20%, #343534 80%, #242424 100%),"
// + " linear-gradient(#8a8a8a 0%, #6b6a6b 20%, #343534 80%, #262626 100%),"
// + " linear-gradient(#777777 0%, #606060 50%, #505250 51%, #2a2b2a 100%);"
// + "-fx-background-insets: 0,1,4,5,6;"
// + "-fx-background-radius: 9,8,5,4,3;"
// + "-fx-padding: 1 1 1 1;"
//// + "-fx-font-family: 'Helvetica';"
// + "-fx-font-size: 12px;"
//// + "-fx-font-weight: bold;"
// + "-fx-opacity: .75;"
// + "-fx-text-fill: white;"
// + "-fx-effect: dropshadow( three-pass-box , rgba(255,255,255,0.2),1 ,0.0 ,0 ,1);"
// );
// mapToolAnchorPane.setOpacity(.75);
mapToolAnchorPane.setPrefHeight(450);
mapToolAnchorPane.setPrefWidth(140);
sMapStackPane.getChildren().add(mapToolAnchorPane);
AnchorPane.setTopAnchor(mapToolAnchorPane, 110.0);
AnchorPane.setRightAnchor(mapToolAnchorPane, 20.0);
createMapButtons();
createMapCacheToggles();
createFXSettlementComboBox();
createFXZoomSlider();
createFXMapLabelBox();
anchorAllMapWidgets();
// detect mouse wheel scrolling
sMapStackPane.setOnScroll(new EventHandler<ScrollEvent>() {
public void handle(ScrollEvent event) {
if (event.getDeltaY() == 0)
return;
double direction = event.getDeltaY();
if (direction > 0) {
// Move zoom slider down.
if (zoomSlider.getValue() > zoomSlider.getMin())
zoomSlider.setValue((zoomSlider.getValue() - 1));
} else if (direction < 0) {
// Move zoom slider up.
if (zoomSlider.getValue() < zoomSlider.getMax())
zoomSlider.setValue((zoomSlider.getValue() + 1));
}
// event.consume();
}
});
}