鐪嬩笅闈emo鐨勪唬鐮?br />
import聽java.awt.Insets;
import聽javax.swing.ImageIcon;
import聽javax.swing.JButton;


public聽class聽ImageButton聽extends聽JButton聽
{

聽聽聽聽private聽static聽final聽long聽serialVersionUID聽=聽7760427126786950870L;


聽聽聽聽public聽ImageButton(ImageIcon聽icon)聽
{
聽聽聽聽聽聽聽聽setSize(icon.getImage().getWidth(null),icon.getImage().getHeight(null));
聽聽聽聽聽聽聽聽setIcon(icon);
聽聽聽聽聽聽聽聽setMargin(new聽Insets(0,0,0,0));
聽聽聽聽聽聽聽聽setIconTextGap(0);
聽聽聽聽聽聽聽聽setBorderPainted(false);
聽聽聽聽聽聽聽聽setBorder(null);
聽聽聽聽聽聽聽聽setText(null);

聽聽聽聽}
}

紼嶅井瑕佽В閲婁竴涓嬬殑鏄button鐨勮竟妗嗛兘璁劇疆鎴愪負0錛岃繕鏈夎竟妗嗙殑閲嶇粯璁劇疆false錛屾垜浠彲浠ョ敤涓嶅悓鐨勮創鍥捐〃紺烘寜閽閫変腑絳夌殑鐘舵?br />
浣跨敤榪欎釜緇勪歡鐨刣emoCode
聽聽聽聽聽聽聽聽ImageButton聽button聽=聽new聽ImageButton("images/*.png");
聽聽聽聽聽聽聽聽button.setPressedIcon(new聽ImageIcon("images/*.png"));
聽聽聽聽聽聽聽聽button.setRolloverIcon(new聽ImageIcon("images/*.png"));
聽聽聽聽聽聽聽聽button.setSelectedIcon(new聽ImageIcon("images/*.png"));
聽聽聽聽聽聽聽聽button.setRolloverSelectedIcon(new聽ImageIcon("images/*.png"));
聽聽聽聽聽聽聽聽button.setDisabledIcon(new聽ImageIcon("images/*.png"));
聽聽聽聽聽聽聽聽button.setDisabledSelectedIcon(new聽ImageIcon("images/*.png"));
榪欎釜Hack瑕佹樉紺烘晥鏋滃ソ錛屽叧閿氨鍦ㄤ簬璐村浘浜嗭紝鍙緹庡伐寰堥噸瑕併?br />
鎴戝噯澶囨瘡澶〩ack涓綃?br />
鏇村鍐呭錛屽彲浠ョ湅Swing Hacks
鍙傝冭祫鏂欙細
聽"Swing Hacks by Joshua Marinacci and Chris Adamson. Copyright 2005 O'Reilly Media, Inc., 0-596-00907-0."
]]>