| 931 | /// |
| 932 | /// - `cmd`: the command on the button |
| 933 | public void setCommand(Command cmd) { |
| 934 | if (this.cmd != null) { |
| 935 | removeActionListener(this.cmd); |
| 936 | } |
| 937 | this.cmd = cmd; |
| 938 | if (cmd != null) { |
| 939 | setText(cmd.getCommandName()); |
| 940 | if (cmd.getIcon() == null) { |
| 941 | if (cmd.getMaterialIcon() != 0) { |
| 942 | if (cmd.getIconFont() != null) { |
| 943 | setFontIcon(cmd.getIconFont(), cmd.getMaterialIcon(), cmd.getMaterialIconSize()); |
| 944 | } else { |
| 945 | setMaterialIcon(cmd.getMaterialIcon(), cmd.getMaterialIconSize()); |
| 946 | } |
| 947 | } |
| 948 | } else { |
| 949 | setIcon(cmd.getIcon()); |
| 950 | } |
| 951 | setEnabled(cmd.isEnabled()); |
| 952 | updateCommand(); |
| 953 | addActionListener(cmd); |
| 954 | } |
| 955 | } |
| 956 | |
| 957 | /// Returns true if the button is selected for toggle buttons, |
| 958 | /// |