import java.awt.Image;
import java.net.URL;
import java.net.URLClassLoader;
import javax.swing.*;
import java.awt.BorderLayout;
public class button extends JFrame{
JButton bu;
button(){
setSize(600,400);
bu=new JButton();
URLClassLoader urlLoader =(URLClassLoader)getClass().getClassLoader();
URL fileLoc = urlLoader.findResource("1.png");
Image img=getToolkit().createImage(fileLoc);
bu.setIcon(new ImageIcon(img));
add(bu,BorderLayout.NORTH);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setVisible(true);
}
public static void main(String[] args){
new button();
}
}
需要把文件名存到数据库下!
zxc