Create a Swing component based on another but with different API

前端 未结 4 1504
礼貌的吻别
礼貌的吻别 2021-01-24 10:36

I would like to create a new Swing JComponent based on an existing one, but with a different API. In other words, I don\'t want to extend the existing component, because I don\'

4条回答
  •  余生分开走
    2021-01-24 11:04

    As shown here, you can use two instances of JToggleButton in a ButtonGroup to "show two buttons ON / OFF." The ButtonGroup causes only one button in the group to be selected at a time. The following change is illustrated:

    private final JLabel label = new JLabel(" \u2713 ");
    

    image

提交回复
热议问题