AnimationPlayer.java 1.7 KB
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.Box;
import javax.swing.BoxLayout;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JPanel;

public class AnimationPlayer extends JPanel implements ActionListener {
	private static final long serialVersionUID = 1L;

	private JButton backward;
	private JButton stop;
	private JButton play;
	private JButton pause;
	private JButton forward;

	public AnimationPlayer() { this(BoxLayout.LINE_AXIS); }
	public AnimationPlayer(int direction) {
		setLayout(new BoxLayout(this, direction));

		add(Box.createHorizontalGlue());
		
		// backward button
		backward = new JButton(new ImageIcon(getClass().getResource("/icons/backward.png")));
		backward.addActionListener(this);
		add(backward);
		
		// stop button
		stop = new JButton(new ImageIcon(getClass().getResource("/icons/stop.png")));
		stop.addActionListener(this);
		add(stop);
		
		// play button
		play = new JButton(new ImageIcon(getClass().getResource("/icons/play.png")));
		play.addActionListener(this);
		add(play);
		
		// pause button
		pause = new JButton(new ImageIcon(getClass().getResource("/icons/pause.png")));
		pause.addActionListener(this);
		add(pause);
		
		// forward button
		forward = new JButton(new ImageIcon(getClass().getResource("/icons/forward.png")));
		forward.addActionListener(this);
		add(forward);

		add(Box.createHorizontalGlue());
	}
	
	@Override
	public void actionPerformed(ActionEvent e) {
		// TODO player actions
		if(e.getSource() == backward) {
			
		}else if(e.getSource() == stop) {
			
		}else if(e.getSource() == play) {
			
		}else if(e.getSource() == pause) {
			
		}else if(e.getSource() == forward) {
			
		}
	}
}