package com.aa;

import java.awt.Component;

import javax.swing.ImageIcon;
import javax.swing.JPanel;
import javax.swing.JLabel;
import javax.swing.JFrame;

public class huatu extends JFrame {
	JPanel panel;
	JLabel label;
	ImageIcon tt;

	public huatu() {

		tt = new ImageIcon(
				"C:\\Users\\Administrator\\workspace\\Demo\\bin\\com\\aa\\3.jpg");
		label = new JLabel(tt);
		panel = new JPanel();
		panel.add(label);

		this.add(panel);
		this.setVisible(true);
		this.setSize(400, 300);

	}

	public static void main(String[] args) {
		huatu t = new huatu();
	}
}

  

总结::路径最重要。添加在当前类的文件夹下面,真的

下图捕获 了

java图形用户界面添加图片的代码

 

相关文章:

  • 2021-10-27
  • 2021-05-17
  • 2021-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-25
  • 2022-01-15
相关资源
相似解决方案