I am making a java applet that have several rectangles of varying sizes that change position and size throughout the program. Is there a way to instead have a rectangular image that changes size and position just like these rectangles?
Asked
Active
Viewed 1,382 times
1 Answers
0
The question depends. Do you want to scale the image and maintain it's aspect ratio or not.
If you do, then you also need to decide if you want the image to fill the available area (possibly overfilling) or fit within.
For more details, check out Java: maintaining aspect ratio of JPanel background image
The easiest solution would be to use Image#getScaledInstance
and simply paint the image using Graphics#drawImage(Image, int, int, ImageObserver)
But you should beware of the issues with this method. See The Perils of Image.getScaledInstance()

Community
- 1
- 1

MadProgrammer
- 343,457
- 22
- 230
- 366