JLabel (@NotNull Extension extension) { JLabel label = new JLabel(extension.getIcon(false)); label.setToolTipText(extension.getTooltip()); label.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); label.addMouseListener(new MouseAdapter() { @Override public void mouseEntered(MouseEvent event) { label.setIcon(extension.getIcon(true)); } @Override public void mouseExited(MouseEvent event) { label.setIcon(extension.getIcon(false)); } @Override public void mouseClicked(MouseEvent event) { Runnable action = extension.getActionOnClick(); if (action != null) action.run(); } }); return label; }