import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
class Mywindow extends JFrame{
JButton b1,b2,b3;
public Mywindow(){
setBounds(100,100,300,300);
setVisible(true);
addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent e){
System.exit(0);
}
});
b1=new JButton( "按钮1 ",new ImageIcon( "a1.gif "));
b2=new JButton( "按钮2 ",new ImageIcon( "a2.gif "));
b3=new JButton( "按钮3 ",new ImageIcon( "a3.gif "));
b1.setRolloverIcon(b2.getIcon());
b2.setRolloverIcon(b3.getIcon());
b3.setRolloverIcon(b1.getIcon());
b1.setHorizontalTextPositon(AbstractButton.LEFT);
b1.setVerticalTextPositon(AbstractButton.TOP);
b2.setHorizontalTextPositon(AbstractButton.RIGHT);
b2.setVerticalTextPositon(AbstractButton.BOTTOM);
b3.setHorizontalTextPositon(AbstractButton.CENTER);
b3.setVerticalTextPositon(AbstractButton.CENTER);
Container con=getContentPane();
con.add(b1);
con.add(b2);
con.add(b3);
con.validate();
}
}
public class JButtonExam{
public static void main(String args[]){
Mywindow win=new Mywindow();
win.pack();
}
}
------解决方案--------------------
是不是有全角字符?首行