我用eclipse编java图形界面 想在标签上插入图片 但是图片总是显示不了?我以为是图片文件路径的问题,但是改了半天还是不行,sss.gif文件我已导入到bin/image下 请教各位高手,下面是我的代码 ,谢谢了public class MapFrame1 extends JFrame{
JMenuBar jmb;
JComboBox jcb;//下拉菜单
JPanel jp;
JLabel jl;//标签
JButton jb1;
/*private static Toolkit tk = Toolkit.getDefaultToolkit();
private static Image imgs = tk.getImage(MapFrame1.class.getClassLoader().getResource("image/sss.gif"));*/
public MapFrame1() {
super("黑龙江大学校园导游系统");
}
public void lanuchFrame() {
this.setExtendedState(MAXIMIZED_BOTH);
JButton jb = new JButton();
jp = new JPanel();
jcb = new JComboBox();
jmb = new JMenuBar();
ImageIcon icon = new ImageIcon("sss.gif");
jl = new JLabel(icon,SwingConstants.CENTER);
jmb.add(jcb);
jp.add(jl);
this.add(jp, "Center");
this.add(jmb, "North");
jp.add(jb, "North");
this.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
}
});
this.setVisible(true); } }
JMenuBar jmb;
JComboBox jcb;//下拉菜单
JPanel jp;
JLabel jl;//标签
JButton jb1;
/*private static Toolkit tk = Toolkit.getDefaultToolkit();
private static Image imgs = tk.getImage(MapFrame1.class.getClassLoader().getResource("image/sss.gif"));*/
public MapFrame1() {
super("黑龙江大学校园导游系统");
}
public void lanuchFrame() {
this.setExtendedState(MAXIMIZED_BOTH);
JButton jb = new JButton();
jp = new JPanel();
jcb = new JComboBox();
jmb = new JMenuBar();
ImageIcon icon = new ImageIcon("sss.gif");
jl = new JLabel(icon,SwingConstants.CENTER);
jmb.add(jcb);
jp.add(jl);
this.add(jp, "Center");
this.add(jmb, "North");
jp.add(jb, "North");
this.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
}
});
this.setVisible(true); } }
JLabel labelNotice0=new JLabel();
labelNotice0.setIcon(img1);