Change selected dot color of JRadioButtonMenuItem

前端 未结 4 845
陌清茗
陌清茗 2020-12-19 10:33

I\'m working on my personal Java chat client whose one feature is setting user\'s status (Available, Invisible, Busy). To make it user-friendly, I put those statuses into a

4条回答
  •  死守一世寂寞
    2020-12-19 11:25

    Add a new class to customize the RadioButtonMenuItem by extending JRadioButtonMenuItem.

    Add inner class to update status Icon by implementing Icon inteface. Override all the methods update the paintIcon() method with current status icon.

    Call super class by passing status icon.

    super(theMenuText, new StatusIcon(theStudyIcon, getUserStatus(UserId)));
    

    Add listner to get the latest event to update the Icon using setIcon() method.

提交回复
热议问题