@Test public void testSetIcon() { Assert.assertNull(new ContextAwareButton(action).getIcon()); Icon icon = new ImageIcon(new BufferedImage(12,12,BufferedImage.TYPE_INT_ARGB)); Mockito.when(action.getValue(Action.SMALL_ICON)).thenReturn(icon); Mockito.when(action.getValue(Action.LARGE_ICON_KEY)).thenReturn(icon); Assert.assertNotNull(new ContextAwareButton(action).getIcon()); Assert.assertNotSame(new ContextAwareButton(action).getIcon(), icon); icon = Mockito.mock(Icon.class); Mockito.when(action.getValue(Action.SMALL_ICON)).thenReturn(icon); Mockito.when(action.getValue(Action.LARGE_ICON_KEY)).thenReturn(icon); Assert.assertEquals(new ContextAwareButton(action).getIcon(), icon); }
@Override public void setIcon(Icon icon) { if (icon != null && icon instanceof ImageIcon) { super.setIcon(MCTIcons.processIcon((ImageIcon) icon, .9f, .9f, .9f, true)); super.setPressedIcon(MCTIcons.processIcon((ImageIcon) icon, 1f, 1f, 1f, true)); } else { super.setIcon(icon); } }
ContextAwareButton extends JButton { @Override public void setIcon(Icon icon) { if (icon != null && icon instanceof ImageIcon) { super.setIcon(MCTIcons.processIcon((ImageIcon) icon, .9f, .9f, .9f, true)); super.setPressedIcon(MCTIcons.processIcon((ImageIcon) icon, 1f, 1f, 1f, true)); } else { super.setIcon(icon); } } }
ContextAwareButton extends JButton { @Override public void setIcon(Icon icon) { if (icon != null && icon instanceof ImageIcon) { super.setIcon(MCTIcons.processIcon((ImageIcon) icon, .9f, .9f, .9f, true)); super.setPressedIcon(MCTIcons.processIcon((ImageIcon) icon, 1f, 1f, 1f, true)); } else { super.setIcon(icon); } } ContextAwareButton(ContextAwareAction action);  ContextAwareButton(ContextAwareAction action, ActionContext context); }
ContextAwareButton extends JButton { @Override public void setIcon(Icon icon) { if (icon != null && icon instanceof ImageIcon) { super.setIcon(MCTIcons.processIcon((ImageIcon) icon, .9f, .9f, .9f, true)); super.setPressedIcon(MCTIcons.processIcon((ImageIcon) icon, 1f, 1f, 1f, true)); } else { super.setIcon(icon); } } ContextAwareButton(ContextAwareAction action);  ContextAwareButton(ContextAwareAction action, ActionContext context); @Override void setIcon(Icon icon); @Override void setText(String text); void setContext(ActionContext context); }
ContextAwareButton extends JButton { @Override public void setIcon(Icon icon) { if (icon != null && icon instanceof ImageIcon) { super.setIcon(MCTIcons.processIcon((ImageIcon) icon, .9f, .9f, .9f, true)); super.setPressedIcon(MCTIcons.processIcon((ImageIcon) icon, 1f, 1f, 1f, true)); } else { super.setIcon(icon); } } ContextAwareButton(ContextAwareAction action);  ContextAwareButton(ContextAwareAction action, ActionContext context); @Override void setIcon(Icon icon); @Override void setText(String text); void setContext(ActionContext context);  }