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

  • SEARCH
  • Home
  • 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 8056239
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T08:38:56+00:00 2026-06-05T08:38:56+00:00

i am trying to run simple JavaFx(2.0) application which will show three images as

  • 0

i am trying to run simple JavaFx(2.0) application which will show three images as thumbnails. OS is Windows7 and i am using NetBeans 7.2
Code is this-

public class FX17 extends Application{

    public static void main(String[] args){
        launch(args);
    }
    public void start(Stage stage){

        HBox photoBar = new HBox();
        Group root = new Group();
        File f1 = new File("C:\\Users\\Pictures\\IMG_0021.jpg");
        File f2 = new File("C:\\Users\\Pictures\\IMG_0022.jpg");
        File f3 = new File("C:\\Users\\Pictures\\IMG_0023.jpg");

        Image i1 = new Image(f1.toURI().toString());
        Image i2 = new Image(f2.toURI().toString());
        Image i3 = new Image(f3.toURI().toString());
        ImageView iv1 = new ImageView(i1);
        //iv1.setImage(i1);
        iv1.setFitWidth(50);
        iv1.setPreserveRatio(true);
        iv1.setCache(true);

        ImageView iv2 = new ImageView(i2);
        //iv2.setImage(i2);
        iv2.setFitWidth(50);
        iv2.setPreserveRatio(true);
        iv2.setCache(true);

        ImageView iv3 = new ImageView(i3);
       // iv3.setImage(i3);
        iv3.setFitWidth(50);
        iv3.setPreserveRatio(true);
        iv3.setCache(true);

       photoBar.getChildren().add(iv1);
        photoBar.getChildren().add(iv2);
        photoBar.getChildren().add(iv3);
        //C:\Users\Public\Pictures\Sample Pictures

        BorderPane pane = new BorderPane();
        pane.setTop(photoBar);
        root.getChildren().add(photoBar);
        //pane.setLeft(linkBar);

        Scene scene = new Scene(root);
        scene.setFill(Color.BLACK);

        stage.setScene(scene);
        stage.setWidth(415);
        stage.setHeight(200);
        stage.sizeToScene();
        stage.show();
    }

}

For two images program runs and shows two thumbnails but for 3 or more images, program throws OutOfMemoryError. Image is jpg and average size is 2.5MB. Are there some setting or image format i need to check ?
Following constructor works fine for me.
Image img = new Image(file.toURI().toString(),100,100,false,false);aspect ratio,smooth is false.

  • 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-05T08:38:57+00:00Added an answer on June 5, 2026 at 8:38 am

    I guess your jpgs are very large in terms of height and width.

    The memory taken by a jpg versus the loaded image buffer is different. The loaded image is a decoded uncompressed bitmap and depends on the image height/width/color depth rather than the original jpg file size.

    To fix your OutOfMemory condition:

    1. Resize the jpgs to a smaller height and width (and/or lower color depth) using an image editor outside your program AND/OR
    2. Only load a single jpg into memory at a time, rather than all three at once AND/OR
    3. Increase the memory available to your java app (e.g. -Xmx1500m) AND/OR
    4. Specify a size in the image constructor rather than the image view.

    Specifying a size in the image constructor ensures that, once the image is loaded, Java only keeps a buffer large enough to hold the resized image rather than the full size, uncompressed image.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to run this seemingly simple piece of code which is repeated
When trying to run a simple JavaFX 2.0 beta application written in Scala 2.8.1
I am trying to run a simple multiple processes application in Python. The main
I am trying to run a simple SQLITE application on Windows Mobile developed with
I am trying to run a simple linear regression (using rpy2 from Python) and
I am using Python 2.6 and am trying to run a simple random number
I am trying to run the following simple code, public abstract class Shape{ abstract
I am newbie with JPA. I'm trying to run some sample code using JPA
I'm trying run a simple Java/MySQL web app tutorial in NetBeans. I am able
I am trying to run a simple program using a spring configuration file. In

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.