MCPcopy Create free account
hub / github.com/codenameone/CodenameOne / setCommand

Method setCommand

CodenameOne/src/com/codename1/ui/Button.java:933–955  ·  view source on GitHub ↗
(Command cmd)

Source from the content-addressed store, hash-verified

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 ///

Callers 9

updateGridCommandsMethod · 0.95
readCommandMethod · 0.95
runMethod · 0.95
createToggleMethod · 0.45
invoke6Method · 0.45
invoke0Method · 0.45

Calls 14

removeActionListenerMethod · 0.95
setTextMethod · 0.95
updateCommandMethod · 0.95
addActionListenerMethod · 0.95
getIconMethod · 0.65
setFontIconMethod · 0.65
setMaterialIconMethod · 0.65
setIconMethod · 0.65
setEnabledMethod · 0.65
isEnabledMethod · 0.65
getCommandNameMethod · 0.45
getMaterialIconMethod · 0.45