最近没事做了一个仿照windows自带图片查看器软件,在用java实现...遇到两个问题1,windows自带的当鼠标箭头移到相应功能键上的时候..出现提示文字,我用的是JButton,请问当鼠标箭头移到JButton上的时候,如何在鼠标箭头处显示文字....只要有组件有这个方法...可以不用JButton...2,幻灯片演示问题..我做的幻灯片没有它的那个好..我的思路是把图片显示在JPanel上(作为背景图片)..大体程序代码结构是...为什么不行(原因注释在代码中)?
public void paintComponent(Graphics g)//重写基类的paintComponent方法
{
super.paintComponent(g);
g.drawImage(icon.getImage(),0,0,this.getSize().width,this.getSize().height,this);
}
.
.
.
.if(e.getSource()==jbslide){
/*
for(int i=1;i<=20;i++){//这里我用了循环方法..不行..运行后就死掉了..(第一种想法)
icon=new ImageIcon(this.getClass().getResource("pic/"+i+".jpg"));
this.repaint();
try {
Thread.sleep(2000);
} catch (Exception e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}

}*/


try {//这里没有用循环..但是只能显示最后一张..sleep起到作用了..但是为什么前面的不能够repaint到呢??(第二种想法)
icon=new ImageIcon(this.getClass().getResource("pic/1.jpg"));
this.repaint();
Thread.sleep(2000);
icon=new ImageIcon(this.getClass().getResource("pic/2.jpg"));
this.repaint();
Thread.sleep(2000);
icon=new ImageIcon(this.getClass().getResource("pic/3.jpg"));
this.repaint();
} catch (Exception e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}有经历过的发表下意见...