簡體   English   中英

選擇后如何更改JButton Icon?

[英]How to change JButton Icon when selected?

我想在用戶按下/釋放按鈕時更改JButton圖標。

選擇JButton時的圖標圖像

在此輸入圖像描述

取消選擇JButton並釋放JButton時的圖標圖像:

未選中/釋放時

我怎樣才能做到這一點?

JButton b = new JButton(Icon x); // Create button with normal icon
   b.setIcon(Icon x);
   b.setDisabledIcon(Icon x);
   b.setPressedIcon(Icon x);
   b.setSelectedIcon(Icon x);
   b.setDisabledSelectedIcon(Icon x);

參考: http//www.leepoint.net/notes-java/GUI/components/20bu​​ttons/23buttonicons.html

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM