Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8521507
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T06:50:50+00:00 2026-06-11T06:50:50+00:00

I am using Java FX and I would like to convert a node to

  • 0

I am using Java FX and I would like to convert a node to an image. I found this resource, but it does not solve my problem as I want to convert a node to an image, not a whole scene.

How to output the content of a Scene graph in JavaFx 2.0 to an Image

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T06:50:52+00:00Added an answer on June 11, 2026 at 6:50 am

    This is solution of my problem. This solution is help of Sergey and jewelsea. This solution is in javafx 2.2. Thanks Sergey and jewelsea.

    public class TrySnapshot extends Application {
    
    javafx.embed.swing.SwingFXUtils fXUtils;
    BufferedImage bufferedImage = new BufferedImage(550, 400, BufferedImage.TYPE_INT_ARGB);
    File file = new File("C:/Users/PC1/Desktop/Sample Images/test.jpg");
    VBox vbox = null;
    
    @Override
    public void start(Stage primaryStage) {
        vbox = new VBox();
        Button btn = new Button();
        Image i = new Image("file:C:\\Koala.jpg");
        ImageView imageView = new ImageView();
        imageView.setImage(i);
        vbox.getChildren().add(imageView);
        vbox.setSpacing(10);
        btn.setText("Say 'Hello World'");
        btn.setOnAction(new EventHandler<ActionEvent>() {
            @Override
            public void handle(ActionEvent event) {
            // here we make image from vbox and add it to scene, can be repeated :)
           WritableImage snapshot = vbox.snapshot(new SnapshotParameters(), null);
               vbox.getChildren().add(new ImageView(snapshot));
                saveImage(snapshot);
                System.out.println(vbox.getChildren().size());
            }
        });
    
    
        Scene scene = new Scene(new Group(btn), 500, 400);
    
        primaryStage.setScene(scene);
        primaryStage.show();
    }
    
    private void saveImage(WritableImage snapshot) {
        BufferedImage image;
        image = javafx.embed.swing.SwingFXUtils.fromFXImage(snapshot, bufferedImage);
        try {
            Graphics2D gd = (Graphics2D) image.getGraphics();
            gd.translate(vbox.getWidth(), vbox.getHeight());
            ImageIO.write(image, "png", file);
        } catch (IOException ex) {
            Logger.getLogger(TrySnapshot.class.getName()).log(Level.SEVERE, null, ex);
        };
      }
     }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to convert an image to 2-color, black and white using Java.
I would like to convert some HTML characters back to text using Java Standard
I'm using Java Property files and would like to have a newline character put
By using paho(java) to build my own MQTT client.I would like to do same
I am using the java MongoDB driver for gridfs and would like to use
I am using the Java version of the Google App Engine. I would like
greetings, today i have started to learn java using netbeans ide. i would like
I would like to connect to java process started by eclipse using a command
I have a few JAVA application that I monitor using JMX. I would like
I'm using Jetty (version 6.1.22) to service a Java web application. I would like

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.