Here you can find the source of getIcon(AbstractButton b)
Parameter | Description |
---|---|
b | Button. |
public static Icon getIcon(AbstractButton b)
//package com.java2s; import javax.swing.*; public class Main { /**//from ww w . j ava 2s .com * Returns the current icon for the specified button. This method is <b>for * internal use only</b>. * * @param b * Button. * @return Icon for the specified button. */ public static Icon getIcon(AbstractButton b) { Icon icon = b.getIcon(); if (icon == null) return null; ButtonModel model = b.getModel(); Icon tmpIcon = null; if (icon != null) { if (!model.isEnabled()) { if (model.isSelected()) { tmpIcon = b.getDisabledSelectedIcon(); } else { tmpIcon = b.getDisabledIcon(); } } else if (model.isPressed() && model.isArmed()) { tmpIcon = b.getPressedIcon(); } else if (b.isRolloverEnabled() && model.isRollover()) { if (model.isSelected()) { tmpIcon = b.getRolloverSelectedIcon(); } else { tmpIcon = b.getRolloverIcon(); } } else if (model.isSelected()) { tmpIcon = b.getSelectedIcon(); } if (tmpIcon != null) { icon = tmpIcon; } } return icon; } }