package example17_1; import java.awt.FlowLayout; import javax.swing.*; public class example17_1 extends JFrame{ public static void main(String[] args) { example17_1 frame = new example17_1(); frame.setVisible(true); } public example17_1(){ super(); setTitle("窗体"); setBounds(100,100,500,375); getContentPane().setLayout(null); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); ImageIcon usIcon = new ImageIcon("pic/3.gif"); ImageIcon caIcon = new ImageIcon("pic/1.gif"); ImageIcon ukIcon = new ImageIcon("pic/2.gif"); JButton jbt = new JButton("Click it",usIcon); jbt.setBounds(110,110,25,25); jbt.setPressedIcon(caIcon); jbt.setRolloverIcon(ukIcon); getContentPane().add(jbt); } }