The ImageIcon class under javax.swing package tends to be overlooked as it contains nifty methods to get an Image’s dimension. Just pass the path of the image file as parameter when you create a new ImageIcon instance then use either the getIconWidth() or getIconHeight() methods to get the width and height respectively.

Related Posts Plugin for WordPress, Blogger...