图片Icon(ImageIcon)

package cn.rushangw.lesson04;

import javax.swing.*;
import java.awt.*;
import java.net.URL;

public class ImageIconDemo extends JFrame{

public ImageIconDemo(){
//获取图片的地址
JLabel jLabel = new JLabel("ImageIcon");
URL url = ImageIconDemo.class.getResource("lADPD3W5ONBVGtTNBDjNB4A_1920_1080.jpg");

ImageIcon imageIcon = new ImageIcon(url);

jLabel.setIcon(imageIcon);
jLabel.setHorizontalAlignment(SwingConstants.CENTER);

Container container = getContentPane();
container.add(jLabel);

setVisible(true);
setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
setBounds(20,20,500,500);

}

public static void main(String[] args) {
new ImageIconDemo();
}
}
上一篇:图标Icon(Icon)


下一篇:CSS3属性transform详解之(旋转:rotate,缩放:scale,倾斜:skew,移动:translate)