avatar
c*t
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.
avatar
n*k
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.

avatar
c*t
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

相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。