如下代码,想让在类UseImage的文件夹内的图片"88.gif"以jbutton的形式显示在frame上,为什么运行了不显示图片呢[code]
import java.awt.*;
import javax.swing.*;
public class UseImage extends JFrame {
JButton bn;
ImageIcon icon;
public UseImage() {
this.setSize(400, 300);
this.setLocation(200, 150);
icon = new ImageIcon("88.jpg");
bn = new JButton("图片", icon);
this.getContentPane().add(bn);
this.setVisible(true);
}
public static void main(String args[]) {
new UseImage();
}
}[/code]
import java.awt.*;
import javax.swing.*;
public class UseImage extends JFrame {
JButton bn;
ImageIcon icon;
public UseImage() {
this.setSize(400, 300);
this.setLocation(200, 150);
icon = new ImageIcon("88.jpg");
bn = new JButton("图片", icon);
this.getContentPane().add(bn);
this.setVisible(true);
}
public static void main(String args[]) {
new UseImage();
}
}[/code]
按你的意思应该是88.gif吧