java - How to scale image using getScaledImage? -


this have tried scale image using getscaledinstance(). not scaling image. can correct code?

bufferedimage image = imageio.read(new file("img.jpg")); jlabel piclabel = new jlabel(new imageicon(image)); image=(bufferedimage)image.getscaledinstance(50,50, image. scale_smooth); add(piclabel); 

creating new image not update imageicon. change order of code:

//bufferedimage image = imageio.read(new file("img.jpg")); //jlabel piclabel = new jlabel(new imageicon(image)); image image = imageio.read(new file("img.jpg")); image=image.getscaledinstance(50,50, image. scale_smooth); jlabel piclabel = new jlabel(new imageicon(image)); add(piclabel); 

edit: original code posted doesn't execute. can't cast scaled image bufferedimage. updated code solve execution problem.


Comments

Popular posts from this blog

How to mention the localhost in android -

php - Calling a template part from a post -

c# - String.format() DateTime With Arabic culture -