javafx.scene.Node类的使用及代码示例

x33g5p2x  于2022-01-24 转载在 其他  
字(9.7k)|赞(0)|评价(0)|浏览(149)

本文整理了Java中javafx.scene.Node类的一些代码示例,展示了Node类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Node类的具体详情如下:
包路径:javafx.scene.Node
类名称:Node

Node介绍

暂无

代码示例

代码示例来源:origin: jfoenixadmin/JFoenix

private void updateDisclosureNode() {
  Node disclosureNode = ((JFXTreeTableCell<S, T>) getSkinnable()).getDisclosureNode();
  if (disclosureNode != null) {
    TreeItem<S> item = getSkinnable().getTreeTableRow().getTreeItem();
    final S value = item == null ? null : item.getValue();
    boolean disclosureVisible = value != null
                  && !item.isLeaf()
                  && value instanceof RecursiveTreeObject
                  && ((RecursiveTreeObject) value).getGroupedColumn() == getSkinnable().getTableColumn();
    disclosureNode.setVisible(disclosureVisible);
    if (!disclosureVisible) {
      getChildren().remove(disclosureNode);
    } else if (disclosureNode.getParent() == null) {
      getChildren().add(disclosureNode);
      disclosureNode.toFront();
    } else {
      disclosureNode.toBack();
    }
    if (disclosureNode.getScene() != null) {
      disclosureNode.applyCss();
    }
  }
}

代码示例来源:origin: stackoverflow.com

/** Places content in a bordered pane with a title. */
class BorderedTitledPane extends StackPane {
 BorderedTitledPane(String titleString, Node content) {
  Label title = new Label(" " + titleString + " ");
  title.getStyleClass().add("bordered-titled-title");
  StackPane.setAlignment(title, Pos.TOP_CENTER);

  StackPane contentPane = new StackPane();
  content.getStyleClass().add("bordered-titled-content");
  contentPane.getChildren().add(content);

  getStyleClass().add("bordered-titled-border");
  getChildren().addAll(title, contentPane);
 }
}

代码示例来源:origin: jfoenixadmin/JFoenix

public void show(Node node) {
    if (text == null) {
      text = (Text) node.lookup(".text");
    }
    node = text;
    if (!isShowing()) {
      if (node.getScene() == null || node.getScene().getWindow() == null) {
        throw new IllegalStateException("Can not show popup. The node must be attached to a scene/window.");
      }
      Window parent = node.getScene().getWindow();
      this.show(parent, parent.getX() +
               node.localToScene(0, 0).getX() +
               node.getScene().getX(),
        parent.getY() + node.localToScene(0, 0).getY() +
        node.getScene().getY() + node.getLayoutBounds().getHeight() + shift);
      ((JFXAutoCompletePopupSkin<T>) getSkin()).animate();
    } else {
      // if already showing update location if needed
      Window parent = node.getScene().getWindow();
      this.show(parent, parent.getX() +
               node.localToScene(0, 0).getX() +
               node.getScene().getX(),
        parent.getY() + node.localToScene(0, 0).getY() +
        node.getScene().getY() + node.getLayoutBounds().getHeight() + shift);
    }
  }
}

代码示例来源:origin: jfoenixadmin/JFoenix

protected void initNode(Node node) {
    node.setScaleX(0);
    node.setScaleY(0);
    node.getStyleClass().add("sub-node");
  }
}

代码示例来源:origin: jfoenixadmin/JFoenix

@Override
public void initAnimation(Node contentContainer, Node overlay) {
  overlay.setOpacity(0);
  contentContainer.setTranslateX(-(contentContainer.getLayoutX()
                   + contentContainer.getLayoutBounds().getMaxX()));
}

代码示例来源:origin: jfoenixadmin/JFoenix

@Override
public void initAnimation(Node contentContainer, Node overlay) {
  overlay.setOpacity(0);
  contentContainer.setTranslateY(-(contentContainer.getLayoutY()
                   + contentContainer.getLayoutBounds().getMaxY()));
}

代码示例来源:origin: stackoverflow.com

Label label = new Label( "This is a Tiger. Tigers are awesome!");
label.relocate(20, 400);
label.setTextFill(Color.RED);
label.setFont(new Font("Tahoma", 48));
Scene scene = new Scene( root, 1024, 768);
primaryStage.setScene( scene);
primaryStage.show();
node.setOnMousePressed(mouseEvent -> {
  dragDelta.x = node.getBoundsInParent().getMinX() - mouseEvent.getScreenX();
  dragDelta.y = node.getBoundsInParent().getMinY() - mouseEvent.getScreenY();
node.setOnMouseDragged(mouseEvent -> node.relocate( mouseEvent.getScreenX() + dragDelta.x, mouseEvent.getScreenY() + dragDelta.y));

代码示例来源:origin: stackoverflow.com

content.getChildren().addAll(parts);
stage.setTitle("Cubic Curve Manipulation Sample");
stage.setScene(new Scene(content, 400, 400, Color.ALICEBLUE));
stage.show();
    control.setVisible(!plot.isSelected());

代码示例来源:origin: stackoverflow.com

);
  Label exportLocation = new Label("Exported to " + imagePath);
  exportLocation.setStyle("");
  exportLocation.getStyleClass().add("overlay-label");
  scene.getStylesheets().add(getClass().getResource(
      "encoder-app.css"
  ).toExternalForm());
  stage.setScene(scene);
  stage.show();
    Paint backgroundFill
) throws IOException {
  if (node.getScene() == null) {
    Scene snapshotScene = new Scene(new Group(node));
  Image chartSnapshot = node.snapshot(params, null);
  PngEncoderFX encoder = new PngEncoderFX(chartSnapshot, true);
  byte[] bytes = encoder.pngEncode();

代码示例来源:origin: at.bestsolution.efxclipse.rt/org.eclipse.fx.ui.controls

public DragFeedbackStage(Node n) {
      this.n = n;
      this.popupWindow = new Stage();
      this.popupWindow.initStyle(StageStyle.TRANSPARENT);
//            this.popupWindow.initOwner(n.getScene().getWindow());
      this.popupWindow.setUserData("findNodeExclude"); //$NON-NLS-1$
      this.popupWindow.setAlwaysOnTop(true);
      StackPane root = new StackPane();
      root.setBackground(new Background(new BackgroundFill(Color.TRANSPARENT, CornerRadii.EMPTY, Insets.EMPTY)));
      Scene value = new Scene(root);
      value.setFill(Color.TRANSPARENT);
      this.popupWindow.setScene(value);
      this.popupWindow.getScene().getStylesheets().setAll(n.getScene().getStylesheets());
      this.popupWindow.getScene().setRoot(root);
    }

代码示例来源:origin: stackoverflow.com

new Label("500: Aug 8, 12:15pm"), 
 new Label("404: Aug 7, 3:27am")
).build();
Label nErrors = new Label();
nErrors.getStyleClass().add("nerrors");
nErrors.textProperty().bind(Bindings.size(errorPane.getChildren()).asString());
layout.setPrefHeight(150);
layout.getStylesheets().add(this.getClass().getResource("titledpanecustomization.css").toExternalForm());
primaryStage.setScene(new Scene(layout));
primaryStage.show();
arrow.setVisible(false);
arrow.setManaged(false);

代码示例来源:origin: stackoverflow.com

VBox vbox = new VBox(20);
scroller.setContent(vbox);
Label bindingLabel = new Label("Binding here");
for (int i = 0; i < 4; i++) {
  vbox.getChildren().add(new Label("Item "+(i+1)));
  vbox.getChildren().add(new Label("Item "+(i+6)));
Label anchor = new Label("Anchor");
bindingLabel.localToSceneTransformProperty().addListener(listener);
primaryStage.setScene(new Scene(root, 600, 400));
primaryStage.show();
Bounds boundsInScene = node.localToScene(node.getBoundsInLocal());
return target.sceneToLocal(boundsInScene);

代码示例来源:origin: stackoverflow.com

BorderPane root = new BorderPane(flow, null, null, button, null);
Scene scene = new Scene(root, 600, 600);
primaryStage.setScene(scene);
primaryStage.show();
  if (child.getBoundsInParent().getMinY() >= y) {
    wrapped.add(child);
pane.setId("Pane "+id);
Label label = new Label(Integer.toString(id));
pane.getChildren().add(label);

代码示例来源:origin: stackoverflow.com

public class DoSlider extends Application {
@Override
public void start(Stage stage) {
  Slider slider = SliderBuilder.create().min(0).max(100).value(50).showTickLabels(true).showTickMarks(true).build();

  stage.setScene(new Scene(new Group(slider)));
  stage.show();

  traverse(slider);
}

public void traverse(Parent node) {
  for (Node subNode : node.getChildrenUnmodifiable()) {
    System.out.println(subNode.getClass().getSimpleName() + " " + subNode.getStyleClass());
    if (subNode instanceof Parent) {
      traverse((Parent)subNode);
    }
  }
}

public static void main(String[] args) {
  launch(DoSlider.class, args);
}

代码示例来源:origin: stackoverflow.com

Parent root = FXMLLoader.load(getClass().getResource("view/bambam"));

// get the source of the event
Object eventSource = event.getSource(); 

// the event only knows its source is some kind of object, however, we
// registered this listener with a button, which is a Node, so we know
// the actual runtime type of the source must be Button (which is a Node)
// So tell the compiler we are confident we can treat this as a Node:

Node sourceAsNode = (Node) eventSource ;

// get the scene containing the Node (i.e. containing the button):
Scene oldScene = sourceAsNode.getScene();

// get the window containing the scene:
Window window = oldScene.getWindow();

// Again, the Scene only knows it is in a Window, but we know we specifically
// put it in a stage. So we can downcast the Window to a Stage:

Stage stage = (Stage) window ;

// Equivalently, just omitting all the intermediate variables:
// Stage stage= (Stage) ((Node) event.getSource()).getScene().getWindow();

Scene scene = new Scene(root);
stage.setScene(scene);
stage.show();

代码示例来源:origin: stackoverflow.com

});
setCenter(new VBox(15.0, new Label("Push and hold for ContextMenu"), textField));
holdTimer.setOnFinished(event -> handler.handle(eventWrapper.content));
node.addEventHandler(MouseEvent.MOUSE_PRESSED, event -> {
  eventWrapper.content = event;
  holdTimer.playFromStart();
});
node.addEventHandler(MouseEvent.MOUSE_RELEASED, event -> holdTimer.stop());
node.addEventHandler(MouseEvent.DRAG_DETECTED, event -> holdTimer.stop());

代码示例来源:origin: stackoverflow.com

stage.setScene(scene);
stage.show();
Bounds chartAreaBounds = chartArea.localToScene(chartArea.getBoundsInLocal());

代码示例来源:origin: stackoverflow.com

@Override public void start(Stage stage) {
 final HTMLEditor htmlEditor = new HTMLEditor();
 stage.setScene(new Scene(htmlEditor));
 stage.show();
 seperator.setVisible(false); seperator.setManaged(false);
  if (url != null && imageNamePattern.matcher(url).matches()) {
   Node button = imageView.getParent().getParent();
   button.setVisible(false); button.setManaged(false);

代码示例来源:origin: org.jfxtras/jfxtras-common

/**
*
* @param node
* @return The Y scene coordinate of the node.
*/
static public double sceneY(Node node) {
  return node.localToScene(node.getBoundsInLocal()).getMinY() + node.getScene().getY();
}

代码示例来源:origin: jfoenixadmin/JFoenix

public void show(Node node){
  if(!isShowing()){
    if(node.getScene() == null || node.getScene().getWindow() == null)
      throw new IllegalStateException("Can not show popup. The node must be attached to a scene/window.");
    Window parent = node.getScene().getWindow();
    this.show(parent, parent.getX() + node.localToScene(0, 0).getX() +
             node.getScene().getX(),
      parent.getY() + node.localToScene(0, 0).getY() +
      node.getScene().getY() + ((Region)node).getHeight());
    ((JFXAutoCompletePopupSkin<T>)getSkin()).animate();
  }
}

相关文章

微信公众号

最新文章

更多

Node类方法