Я хотел бы показать пользовательский узел как содержимое ControlFx NotificationPane. Я пробовал и помещал настраиваемый узел в качестве параметра в класс NotificationPane, например NotificationPane np = new NotificationPane(customNode)
, но не показывал. Я сделал простой класс, чтобы продемонстрировать, что я только что объяснил.NotificationPane, не отображающий пользовательский узел
import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.control.TableView;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;
import org.controlsfx.control.NotificationPane;
public class NotificationPaneExample extends Application{
public static void main(String[] args) { Application.launch(args); }
@Override
public void start(Stage primaryStage) throws Exception {
VBox root = new VBox();
TableView tv = new TableView();
Label customNode = new Label("This is a custom made node");
NotificationPane np = new NotificationPane(customNode);
np.setContent(tv);
Button button = new Button("Add");
button.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
np.show();
}
});
root.getChildren().addAll(button, np);
primaryStage.setTitle("Notification Pane Example");
Scene scene = new Scene(root);
primaryStage.setScene(scene);
primaryStage.show();
}
}
Потому что я хотел бы обычай узел, чтобы скользить вниз от родительского узла, например, в этом случае TableView –