首页 > 编程语言 > 详细

Java Swing 之查看图标信息

时间:2014-05-04 00:31:01      阅读:525      评论:0      收藏:0      [点我收藏+]
/**
 *查看图标的信息
 *@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("查看图标信息");
		this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		this.setBounds(100, 100, 300, 150);
		JPanel contentPane=new JPanel();
		contentPane.setBorder(new EmptyBorder(5,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.getIconWidth()+",");
	    sb.append("图标高度:"+icon.getIconHeight());
	    label.setText(sb.toString());
	    contentPane.add(label);
	    this.setVisible(true);
	}
    public static void main(String []args){
    	ImageInfoDemo example=new ImageInfoDemo();
    }
}
bubuko.com,布布扣

Java Swing 之查看图标信息,布布扣,bubuko.com

Java Swing 之查看图标信息

原文:http://blog.csdn.net/guanjungao/article/details/24888091

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!