I am trying to create a program that will display all images from a folder on my computer in 2 columns on a JFrame Canvas and allow me to scroll the page to see all the images.
Currently my program will only display the pictures until there is no more space on the screen. But, I want my program to load all of the images and allow me to scroll through them.
Attached are screenshots of:
1) Main Class, where I create my JFrame and JScrollBar
2) Paint Method, where I display the images to the Canvas
3) Current program which loads images in 2 columns but stops loading images as soon as the screen is filled
Current program showing images displayed on Canvas
Is there something simple that I am just overlooking on how to load all of the images so my program will function as intended? Any advice is greatly appreciated.
(Posted solution on behalf of the question author).
In my Main Class I create a JFrame Display System called runDisplay
to solve the issue mentioned above, runDisplay.setSize(width,height)
must be added after the JFrame is created. Then, the program will load all images as long as they are within the width and height parameters passed to .setSize()
.