Resize Image Java Swing. Newheight numberutil convert new double longer double oldheight double oldwidth 0 intvalue. Int newwidth 1.
Jlabel seticon new imageicon new javax swing imageicon getclass getresource res image png getimage getscaledinstance 200 50 image scale smooth. Then use getimage to grab the image from the imageicon. Using the image getscaledinstance method will not guarantee that the aspect ratio of the original image will be maintained for the resized image and furthermore it is in general very slow.
Int newheight 1.
Then blit the icon image to the buffered image and resize it as you do so. Public static bufferedimage resizeimage bufferedimage image int longer int width int height boolean iswithhint int oldwidth image getwidth. Newheight numberutil convert new double longer double oldheight double oldwidth 0 intvalue. Create a bufferedimage object for the output image.