/*** View the icon information * @ author gao */package com. gao; import java. awt. flowLayout; import javax. swing. imageIcon; import javax. swing. JFrame; import javax. swing. JLabel; import javax. swing. JPanel; import javax. swing. border. emptyBorder; public class ImageInfoDemo extends JFrame {public ImageInfoDemo () {this. setTitle ("view icon information"); this. setdefaclocloseoperation (JFrame. EXIT_ON_CLOSE); this. setBounds (100,100,300,150); JPanel contentPane = new JPanel (); contentPane. setBorder (new EmptyBorder (5, 5, 5); this. setContentPane (contentPane); contentPane. setLayout (new FlowLayout (FlowLayout. CENTER, 5, 5); JLabel label = new JLabel (""); ImageIcon icon = new ImageIcon ("1.png"); label. setIcon (icon); StringBuilder sb = new StringBuilder (); sb. append ("icon width:" + icon. getIconWidth () + ","); sb. append ("icon Height:" + icon. getIconHeight (); label. setText (sb. toString (); contentPane. add (label); this. setVisible (true);} public static void main (String [] args) {ImageInfoDemo example = new ImageInfoDemo ();}}