I want to display image on the Jpanel. For standard screen size the image of width x height = 220x45 is displayed properly. To the constructor ImagePanel
I'm passing the image url with it's height and width and the image is being displayed properly. Now if I launch the Swing application on large monitors the image gets blurry, so I make another image of high resolution dpi. Here how to determine the image's new height and width for resizing the image for different screen sizes?
imagePanel = new ImagePanel("images/logo-header.png", 220, 45);
public ImagePanel(String url, int w, int h) {
try {
InputStream is = getFileFromResourceAsStream(url);
image = ImageIO.read(is);
imageurl = url;
width=w;
height=h;
isScaled = true;
outputImage = new BufferedImage(w,h, image.getType());
} catch (IOException ex) {
ex.printStackTrace();
}
}