1 如何在java的按钮中添加图片背景
import java.awt.BorderLayout;
import java.awt.Container;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
public class Subframe extends JFrame {
JButton b;
public static void main(String args[]) {
new Subframe();
}
public Subframe() {
Container con=this.getContentPane();
con.setBounds(100,100,800,590);
setDefaultCloseOperation(EXIT_ON_CLOSE);
b=new JButton(new ImageIcon("1.ico"));
con.setLayout(new BorderLayout());
con.add(b,"Center");
setVisible(true);
}
}
我想知道加入图片的具体地址要怎么写啊??
写相对地址行不行??怎么写??