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

Method setIcon

CodenameOne/src/com/codename1/ui/Label.java:678–707  ·  view source on GitHub ↗
(Image icon)

Source from the content-addressed store, hash-verified

676 ///
677 /// - `icon`: the image that the label presents.
678 @Override
679 public void setIcon(Image icon) {
680 if (this.icon == icon) { //NOPMD CompareObjectsWithEquals
681 return;
682 }
683 if (this.icon != null) {
684 this.icon.removeActionListener(iconChangeListener);
685 iconChangeListenerInstalled = false;
686 }
687 widthAtLastCheck = -1;
688 if (icon != null) {
689 if (icon.requiresDrawImage()) {
690 legacyRenderer = true;
691 }
692
693 if (mask != null) {
694 maskedIcon = icon.applyMaskAutoScale(mask);
695 }
696 }
697 this.icon = icon;
698 if (this.icon != null) {
699 if (isInitialized()) {
700 this.icon.addActionListener(iconChangeListener);
701 iconChangeListenerInstalled = true;
702 }
703 }
704 setShouldCalcPreferredSize(true);
705 checkAnimation();
706 repaint();
707 }
708
709 /// Returns the vertical alignment of the Label, this will only work when the icon
710 /// is in the side of the text and not above or below it.

Callers 15

ShareFormMethod · 0.95
setHintMethod · 0.95
setIconMethod · 0.95
handleImageMethod · 0.95
setComponentValueMethod · 0.95
rebuildInspectorMethod · 0.95
UserFormMethod · 0.95
TheFormMethod · 0.95
startMethod · 0.95

Calls 8

checkAnimationMethod · 0.95
applyMaskAutoScaleMethod · 0.80
removeActionListenerMethod · 0.65
addActionListenerMethod · 0.65
repaintMethod · 0.65
requiresDrawImageMethod · 0.45
isInitializedMethod · 0.45

Tested by 10

UserFormMethod · 0.76
ShaiFormMethod · 0.76
ShaiFormMethod · 0.76
testSetIconMethod · 0.76
testSetIconNullMethod · 0.76
UserFormMethod · 0.76