我想在按纽里面放一张小图片但是无法实现1不知道是怎么搞的1希望可以得到答案
我的程序如下:
package bb;
import java.awt.BorderLayout;
import javax.swing.JFrame;
import javax.swing.JPanel;
import java.awt.Rectangle;
import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.ImageIcon;
public class Frame1 extends JFrame
{
public Frame1()
{
try
{
jbInit();
}
catch (Exception exception)
{
exception.printStackTrace();
}
}
private void jbInit() throws Exception
{
getContentPane().setLayout(null);
jButton1.setBounds(new Rectangle(59, 51, 307, 164));
jButton1.setText("jButton1");
jButton1.setIcon(img1);
this.getContentPane().add(jButton1);
}
public static void main(String[] args)
{
Frame1 frame1 = new Frame1();
frame1.setSize(500,500);
frame1.show();
}
JButton jButton1 = new JButton();
ImageIcon img1 =new ImageIcon("1.gif") ;
ImageIcon img2 =new ImageIcon("2.gif") ;
ImageIcon img3=new ImageIcon("3.gif") ;
}