public LyricsPanel() {
setLayout(new BorderLayout());
final JTextPane textPane = new TextPane();
final Player player = app.getPlayer();
timer = new Timer(200, new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
Track track = player.getTrack();
try {
textPane.setText("");
StyledDocument doc = textPane.getStyledDocument();
doc.insertString(doc.getLength(), track.getTrackData().getArtist() + "\n", textPane.getStyle("artist"));
doc.insertString(doc.getLength(), track.getTrackData().getTitle() + "\n\n", textPane.getStyle("title"));
} catch (BadLocationException e1) {
e1.printStackTrace();
}
if (search != null && !search.isDone())
search.cancel(true);
search = new Search(textPane, track);
search.execute();
timer.stop();
}
});
player.addListener(new PlayerListener() {
@Override
public void onEvent(PlayerEvent e) {
switch (e.getEventCode()) {
case FILE_OPENED:
timer.restart();