在JPanel中包括jpg [英] including jpg in JPanel

查看:69
本文介绍了在JPanel中包括jpg的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是代码

this is the code

class ImgPanel extends JPanel{
public void paintComponent(Graphics g){
Image img=new ImageIcon("test/19.jpeg").getImage();
g.drawImage(img, 0, 0, this);
}
}



这是问题....



and here is the question....
in which folder sould I put the jpg file so this code works??

推荐答案

必须在与bin相同级别的文件夹中放置一个名为"test"的文件夹, src文件夹.只需将19.jpeg放入其中.
There has to be a folder named "test" on the same level as your bin and src folders. Just put the 19.jpeg into it.


这篇关于在JPanel中包括jpg的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆