java编程里面,,,为什么看不到显示图片啊
1个回答
2015-02-21
展开全部
import java.awt.GridLayout;
import java.awt.Toolkit;
import java.io.File;
import java.io.IOException;
import javax.imageio.ImageIO;
import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JLabel;
public class YuGiOh extends JFrame
{
private static final long serialVersionUID = 1L;
public YuGiOh ()
{
ImageIcon icon;
try
{
icon = new ImageIcon (ImageIO.read (YuGiOh.class.getResource ("../image/icon.png")));
add (new JLabel (icon));
System.out.println (icon.getIconHeight ());
}
catch (IOException e)
{
e.printStackTrace ();
}
}
public static void main ( String[] imei )
{
YuGiOh yuGiOh = new YuGiOh ();
yuGiOh.setSize (200, 200);
yuGiOh.setLocationRelativeTo (null);
yuGiOh.setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE);
yuGiOh.setVisible (true);
}
}
追问
哇哦,你用的什么么编译器啊,能不能把你编的这个给我钻研一下代码啊,好好奇
追答
也是eclipse啊,看界面就知道了,还用问,代码都粘贴上去了,又来问?你都是问的废话,分分拿来,其余面谈分分拿来,其余面谈分分拿来,其余面谈
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询