ads/auto.txt

Resize Image In Java Swing

All About Image

Resize Image In Java Swing. Ok here s one way of doing it. Imageio write resizeimagehintjpg jpg new file c image mkyong hint jpg.

How To Dynamically Control Auto Resize Components In Java Swing Stack Overflow
How To Dynamically Control Auto Resize Components In Java Swing Stack Overflow from stackoverflow.com

Bufferedimage resizeimagejpg resizeimage originalimage type. You can use imageicon class to load your image file and then simply call getter method to get the image. Ok here s one way of doing it.

The first parameter is a image class which you can easily get from imageicon class.

Let s see the simple example of displaying image in swing. Displaying image in swing with example. You need to use java s graphics 2d to scale the image. Jlabel seticon new imageicon new javax swing imageicon getclass getresource res image png getimage getscaledinstance 200 50 image scale smooth.