import javax.swing.*;
import java.awt.*;
class ShowJButton extends JFrame
{
JButton jb1=new JButton ("up");
ImageIcon im1 =new ImageIcon("D:\\图片\\105");
JButton jb2=new JButton("down",im1);
ImageIcon im2=new ImageIcon("D:\\图片\\100");
JButton jb3 =new JButton(im2);
FlowLayout fl =new FlowLayout();
ShowJButton()
{
super("testing...");
setSize(200,150);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
jb3.setToolTipText("out");
this.getContentPane().setLayout(fl);
this.getContentPane().add(jb1);
this.getContentPane().add(jb2);
this.getContentPane().add(jb3);
show();
}
public static void main(String[]args)
{
ShowJButton sjb=new ShowJButton();
}
}
按钮上图象都不能显示,求助!
----------------解决方案--------------------------------------------------------
怎么能用绝对路径呢?做一个包放图片 比如:
Icon I1 = new ImageIcon("com/StockMarket/GUI/Image/history.gif");
----------------解决方案--------------------------------------------------------