c*****t 发帖数: 1879 | 1 I could like to create JToggleButon and JCheckboxMenuItem based on
a single action and being able to synchronize their states. Is it
possible? It seemed very tedious to me since I'd like to create
buttons/menus from script and being able to group actions (buttons
and menu items then would automatically inherit it).
Anyone has done it before? Thanks. | n*****k 发帖数: 123 | 2
I do not really understand what are you trying to accomplish. But I will try
to answer it anyway.
First you can either create a common ActionListener or use a class that
implements ActoinListener interface for that purpose, after you creating
JToggleButton and JCheckboxMenuItem, do not forget to calle their
addActionListener method to add the common one to their listener list, also
add them to an ArrayList or whatever collection you want to use, so that you
can remember how many of them need to
【在 c*****t 的大作中提到】 : I could like to create JToggleButon and JCheckboxMenuItem based on : a single action and being able to synchronize their states. Is it : possible? It seemed very tedious to me since I'd like to create : buttons/menus from script and being able to group actions (buttons : and menu items then would automatically inherit it). : Anyone has done it before? Thanks.
| c*****t 发帖数: 1879 | 3 Great. The later method you mentioned is exactly what I needed.
【在 n*****k 的大作中提到】 : : I do not really understand what are you trying to accomplish. But I will try : to answer it anyway. : First you can either create a common ActionListener or use a class that : implements ActoinListener interface for that purpose, after you creating : JToggleButton and JCheckboxMenuItem, do not forget to calle their : addActionListener method to add the common one to their listener list, also : add them to an ArrayList or whatever collection you want to use, so that you : can remember how many of them need to
|
|