1 /* 2 * aTunes 3 * Copyright (C) Alex Aranda, Sylvain Gaudard and contributors 4 * 5 * See http://www.atunes.org/wiki/index.php?title=Contributing for information about contributors 6 * 7 * http://www.atunes.org 8 * http://sourceforge.net/projects/atunes 9 * 10 * This program is free software; you can redistribute it and/or 11 * modify it under the terms of the GNU General Public License 12 * as published by the Free Software Foundation; either version 2 13 * of the License, or (at your option) any later version. 14 * 15 * This program is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU General Public License for more details. 19 */ 20 21 package net.sourceforge.atunes.gui.views.controls; 22 23 import java.awt.Dimension; 24 25 import javax.swing.Action; 26 import javax.swing.JButton; 27 28 import net.sourceforge.atunes.model.IControlButton; 29 import net.sourceforge.atunes.model.IIconFactory; 30 import net.sourceforge.atunes.model.ILookAndFeelChangeListener; 31 import net.sourceforge.atunes.model.ILookAndFeelManager; 32 33 /** 34 * Next button 35 * 36 * @author alex 37 * 38 */ 39 public final class NextButton extends JButton implements 40 ILookAndFeelChangeListener, IControlButton { 41 42 private static final long serialVersionUID = -4939372038840047335L; 43 44 private Dimension previousNextButtonSize; 45 46 private ILookAndFeelManager lookAndFeelManager; 47 48 private IIconFactory nextIcon; 49 50 /** 51 * @param nextIcon 52 */ setNextIcon(final IIconFactory nextIcon)53 public void setNextIcon(final IIconFactory nextIcon) { 54 this.nextIcon = nextIcon; 55 } 56 57 /** 58 * @param lookAndFeelManager 59 */ setLookAndFeelManager( final ILookAndFeelManager lookAndFeelManager)60 public void setLookAndFeelManager( 61 final ILookAndFeelManager lookAndFeelManager) { 62 this.lookAndFeelManager = lookAndFeelManager; 63 } 64 65 /** 66 * @param previousNextButtonSize 67 */ setPreviousNextButtonSize(final Dimension previousNextButtonSize)68 public void setPreviousNextButtonSize(final Dimension previousNextButtonSize) { 69 this.previousNextButtonSize = previousNextButtonSize; 70 } 71 72 /** 73 * Instantiates a new next button. 74 * 75 * @param nextAction 76 */ NextButton(final Action nextAction)77 public NextButton(final Action nextAction) { 78 super(nextAction); 79 } 80 81 /** 82 * Initialize button 83 */ initialize()84 public void initialize() { 85 setPreferredSize(this.previousNextButtonSize); 86 setMinimumSize(this.previousNextButtonSize); 87 setMaximumSize(this.previousNextButtonSize); 88 setFocusable(false); 89 setText(null); 90 updateIcon(); 91 this.lookAndFeelManager.getCurrentLookAndFeel().putClientProperties( 92 this); 93 this.lookAndFeelManager.addLookAndFeelChangeListener(this); 94 } 95 96 @Override lookAndFeelChanged()97 public void lookAndFeelChanged() { 98 updateIcon(); 99 } 100 updateIcon()101 private void updateIcon() { 102 setIcon(this.nextIcon.getIcon(this.lookAndFeelManager 103 .getCurrentLookAndFeel().getPaintForSpecialControls())); 104 } 105 } 106