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

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

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

Node介绍

暂无

代码示例

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

  1. private void updateDisclosureNode() {
  2. Node disclosureNode = ((JFXTreeTableCell<S, T>) getSkinnable()).getDisclosureNode();
  3. if (disclosureNode != null) {
  4. TreeItem<S> item = getSkinnable().getTreeTableRow().getTreeItem();
  5. final S value = item == null ? null : item.getValue();
  6. boolean disclosureVisible = value != null
  7. && !item.isLeaf()
  8. && value instanceof RecursiveTreeObject
  9. && ((RecursiveTreeObject) value).getGroupedColumn() == getSkinnable().getTableColumn();
  10. disclosureNode.setVisible(disclosureVisible);
  11. if (!disclosureVisible) {
  12. getChildren().remove(disclosureNode);
  13. } else if (disclosureNode.getParent() == null) {
  14. getChildren().add(disclosureNode);
  15. disclosureNode.toFront();
  16. } else {
  17. disclosureNode.toBack();
  18. }
  19. if (disclosureNode.getScene() != null) {
  20. disclosureNode.applyCss();
  21. }
  22. }
  23. }

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

  1. /** Places content in a bordered pane with a title. */
  2. class BorderedTitledPane extends StackPane {
  3. BorderedTitledPane(String titleString, Node content) {
  4. Label title = new Label(" " + titleString + " ");
  5. title.getStyleClass().add("bordered-titled-title");
  6. StackPane.setAlignment(title, Pos.TOP_CENTER);
  7. StackPane contentPane = new StackPane();
  8. content.getStyleClass().add("bordered-titled-content");
  9. contentPane.getChildren().add(content);
  10. getStyleClass().add("bordered-titled-border");
  11. getChildren().addAll(title, contentPane);
  12. }
  13. }

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

  1. public void show(Node node) {
  2. if (text == null) {
  3. text = (Text) node.lookup(".text");
  4. }
  5. node = text;
  6. if (!isShowing()) {
  7. if (node.getScene() == null || node.getScene().getWindow() == null) {
  8. throw new IllegalStateException("Can not show popup. The node must be attached to a scene/window.");
  9. }
  10. Window parent = node.getScene().getWindow();
  11. this.show(parent, parent.getX() +
  12. node.localToScene(0, 0).getX() +
  13. node.getScene().getX(),
  14. parent.getY() + node.localToScene(0, 0).getY() +
  15. node.getScene().getY() + node.getLayoutBounds().getHeight() + shift);
  16. ((JFXAutoCompletePopupSkin<T>) getSkin()).animate();
  17. } else {
  18. // if already showing update location if needed
  19. Window parent = node.getScene().getWindow();
  20. this.show(parent, parent.getX() +
  21. node.localToScene(0, 0).getX() +
  22. node.getScene().getX(),
  23. parent.getY() + node.localToScene(0, 0).getY() +
  24. node.getScene().getY() + node.getLayoutBounds().getHeight() + shift);
  25. }
  26. }
  27. }

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

  1. protected void initNode(Node node) {
  2. node.setScaleX(0);
  3. node.setScaleY(0);
  4. node.getStyleClass().add("sub-node");
  5. }
  6. }

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

  1. @Override
  2. public void initAnimation(Node contentContainer, Node overlay) {
  3. overlay.setOpacity(0);
  4. contentContainer.setTranslateX(-(contentContainer.getLayoutX()
  5. + contentContainer.getLayoutBounds().getMaxX()));
  6. }

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

  1. @Override
  2. public void initAnimation(Node contentContainer, Node overlay) {
  3. overlay.setOpacity(0);
  4. contentContainer.setTranslateY(-(contentContainer.getLayoutY()
  5. + contentContainer.getLayoutBounds().getMaxY()));
  6. }

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

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

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

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

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

  1. );
  2. Label exportLocation = new Label("Exported to " + imagePath);
  3. exportLocation.setStyle("");
  4. exportLocation.getStyleClass().add("overlay-label");
  5. scene.getStylesheets().add(getClass().getResource(
  6. "encoder-app.css"
  7. ).toExternalForm());
  8. stage.setScene(scene);
  9. stage.show();
  10. Paint backgroundFill
  11. ) throws IOException {
  12. if (node.getScene() == null) {
  13. Scene snapshotScene = new Scene(new Group(node));
  14. Image chartSnapshot = node.snapshot(params, null);
  15. PngEncoderFX encoder = new PngEncoderFX(chartSnapshot, true);
  16. byte[] bytes = encoder.pngEncode();

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

  1. public DragFeedbackStage(Node n) {
  2. this.n = n;
  3. this.popupWindow = new Stage();
  4. this.popupWindow.initStyle(StageStyle.TRANSPARENT);
  5. // this.popupWindow.initOwner(n.getScene().getWindow());
  6. this.popupWindow.setUserData("findNodeExclude"); //$NON-NLS-1$
  7. this.popupWindow.setAlwaysOnTop(true);
  8. StackPane root = new StackPane();
  9. root.setBackground(new Background(new BackgroundFill(Color.TRANSPARENT, CornerRadii.EMPTY, Insets.EMPTY)));
  10. Scene value = new Scene(root);
  11. value.setFill(Color.TRANSPARENT);
  12. this.popupWindow.setScene(value);
  13. this.popupWindow.getScene().getStylesheets().setAll(n.getScene().getStylesheets());
  14. this.popupWindow.getScene().setRoot(root);
  15. }

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

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

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

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

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

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

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

  1. public class DoSlider extends Application {
  2. @Override
  3. public void start(Stage stage) {
  4. Slider slider = SliderBuilder.create().min(0).max(100).value(50).showTickLabels(true).showTickMarks(true).build();
  5. stage.setScene(new Scene(new Group(slider)));
  6. stage.show();
  7. traverse(slider);
  8. }
  9. public void traverse(Parent node) {
  10. for (Node subNode : node.getChildrenUnmodifiable()) {
  11. System.out.println(subNode.getClass().getSimpleName() + " " + subNode.getStyleClass());
  12. if (subNode instanceof Parent) {
  13. traverse((Parent)subNode);
  14. }
  15. }
  16. }
  17. public static void main(String[] args) {
  18. launch(DoSlider.class, args);
  19. }

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

  1. Parent root = FXMLLoader.load(getClass().getResource("view/bambam"));
  2. // get the source of the event
  3. Object eventSource = event.getSource();
  4. // the event only knows its source is some kind of object, however, we
  5. // registered this listener with a button, which is a Node, so we know
  6. // the actual runtime type of the source must be Button (which is a Node)
  7. // So tell the compiler we are confident we can treat this as a Node:
  8. Node sourceAsNode = (Node) eventSource ;
  9. // get the scene containing the Node (i.e. containing the button):
  10. Scene oldScene = sourceAsNode.getScene();
  11. // get the window containing the scene:
  12. Window window = oldScene.getWindow();
  13. // Again, the Scene only knows it is in a Window, but we know we specifically
  14. // put it in a stage. So we can downcast the Window to a Stage:
  15. Stage stage = (Stage) window ;
  16. // Equivalently, just omitting all the intermediate variables:
  17. // Stage stage= (Stage) ((Node) event.getSource()).getScene().getWindow();
  18. Scene scene = new Scene(root);
  19. stage.setScene(scene);
  20. stage.show();

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

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

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

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

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

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

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

  1. /**
  2. *
  3. * @param node
  4. * @return The Y scene coordinate of the node.
  5. */
  6. static public double sceneY(Node node) {
  7. return node.localToScene(node.getBoundsInLocal()).getMinY() + node.getScene().getY();
  8. }

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

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

相关文章

Node类方法