Now using glyphicons for media controls.
@ -17,6 +17,7 @@ class LibraryConfigGUI {
|
|||||||
frame.setContentPane(createUI());
|
frame.setContentPane(createUI());
|
||||||
frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
|
frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
|
||||||
frame.setSize(300, 200);
|
frame.setSize(300, 200);
|
||||||
|
frame.setMinimumSize(new Dimension(300, 200));
|
||||||
frame.setVisible(true);
|
frame.setVisible(true);
|
||||||
updateLibraryListContents();
|
updateLibraryListContents();
|
||||||
}
|
}
|
||||||
|
@ -12,10 +12,12 @@ import musicplayer.model.Artist;
|
|||||||
import musicplayer.model.HasSongs;
|
import musicplayer.model.HasSongs;
|
||||||
import musicplayer.model.Song;
|
import musicplayer.model.Song;
|
||||||
import musicplayer.swingmodels.PlaylistTableModel;
|
import musicplayer.swingmodels.PlaylistTableModel;
|
||||||
|
import musicplayer.util.Icons;
|
||||||
import musicplayer.util.LibraryUtils;
|
import musicplayer.util.LibraryUtils;
|
||||||
import musicplayer.util.PlaylistUtils;
|
import musicplayer.util.PlaylistUtils;
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
|
import javax.swing.event.HyperlinkEvent;
|
||||||
import javax.swing.filechooser.FileNameExtensionFilter;
|
import javax.swing.filechooser.FileNameExtensionFilter;
|
||||||
import javax.swing.tree.DefaultMutableTreeNode;
|
import javax.swing.tree.DefaultMutableTreeNode;
|
||||||
import javax.swing.tree.DefaultTreeModel;
|
import javax.swing.tree.DefaultTreeModel;
|
||||||
@ -27,7 +29,10 @@ import java.awt.event.MouseEvent;
|
|||||||
import java.awt.event.MouseListener;
|
import java.awt.event.MouseListener;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.net.URISyntaxException;
|
||||||
|
import java.nio.file.Files;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
|
import java.nio.file.Paths;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.atomic.AtomicBoolean;
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
@ -77,6 +82,7 @@ public class PlayerGUI implements PlayerCallbackInterface, LibraryCallbackInterf
|
|||||||
DatabaseManager.init();
|
DatabaseManager.init();
|
||||||
PlayerGUI playerGUI = new PlayerGUI();
|
PlayerGUI playerGUI = new PlayerGUI();
|
||||||
JFrame frame = new JFrame();
|
JFrame frame = new JFrame();
|
||||||
|
frame.setMinimumSize(new Dimension(600, 400));
|
||||||
frame.setContentPane(playerGUI.mainPanel);
|
frame.setContentPane(playerGUI.mainPanel);
|
||||||
frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
|
frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
|
||||||
frame.pack();
|
frame.pack();
|
||||||
@ -362,9 +368,10 @@ public class PlayerGUI implements PlayerCallbackInterface, LibraryCallbackInterf
|
|||||||
private JToolBar createControlButtons() {
|
private JToolBar createControlButtons() {
|
||||||
JToolBar toolBar = new JToolBar();
|
JToolBar toolBar = new JToolBar();
|
||||||
toolBar.setFloatable(false);
|
toolBar.setFloatable(false);
|
||||||
JButton playButton = new JButton("Play");
|
JPanel controlBar = new JPanel(new GridLayout(1, 5));
|
||||||
|
JButton playButton = new JButton();
|
||||||
|
playButton.setIcon(Icons.playIcon);
|
||||||
playButton.setMnemonic('P');
|
playButton.setMnemonic('P');
|
||||||
playButton.setDisplayedMnemonicIndex(0);
|
|
||||||
playButton.addActionListener(e -> {
|
playButton.addActionListener(e -> {
|
||||||
if (playList.getRowCount() > 0) {
|
if (playList.getRowCount() > 0) {
|
||||||
if (playList.getSelectedRowCount() > 0)
|
if (playList.getSelectedRowCount() > 0)
|
||||||
@ -373,28 +380,31 @@ public class PlayerGUI implements PlayerCallbackInterface, LibraryCallbackInterf
|
|||||||
playSong(playlistTableModel.getFirst());
|
playSong(playlistTableModel.getFirst());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
toolBar.add(playButton);
|
controlBar.add(playButton);
|
||||||
JButton pauseButton = new JButton("Pause");
|
JButton pauseButton = new JButton();
|
||||||
|
pauseButton.setIcon(Icons.pauseIcon);
|
||||||
pauseButton.setMnemonic('E');
|
pauseButton.setMnemonic('E');
|
||||||
pauseButton.addActionListener(e -> {
|
pauseButton.addActionListener(e -> {
|
||||||
player.pause();
|
player.pause();
|
||||||
setSongHighlighting(player.getCurrentSong()); // Resume won't function if a different song is selected.
|
setSongHighlighting(player.getCurrentSong()); // Resume won't function if a different song is selected.
|
||||||
});
|
});
|
||||||
toolBar.add(pauseButton);
|
controlBar.add(pauseButton);
|
||||||
JButton stopButton = new JButton("Stop");
|
JButton stopButton = new JButton();
|
||||||
|
stopButton.setIcon(Icons.stopIcon);
|
||||||
stopButton.setMnemonic('S');
|
stopButton.setMnemonic('S');
|
||||||
stopButton.setDisplayedMnemonicIndex(0);
|
|
||||||
stopButton.addActionListener(e -> player.stop());
|
stopButton.addActionListener(e -> player.stop());
|
||||||
toolBar.add(stopButton);
|
controlBar.add(stopButton);
|
||||||
JButton previousButton = new JButton("Previous");
|
JButton previousButton = new JButton();
|
||||||
|
previousButton.setIcon(Icons.prevIcon);
|
||||||
previousButton.setMnemonic('R');
|
previousButton.setMnemonic('R');
|
||||||
previousButton.addActionListener(e -> playPreviousSong());
|
previousButton.addActionListener(e -> playPreviousSong());
|
||||||
toolBar.add(previousButton);
|
controlBar.add(previousButton);
|
||||||
JButton nextButton = new JButton("Next");
|
JButton nextButton = new JButton();
|
||||||
|
nextButton.setIcon(Icons.nextIcon);
|
||||||
nextButton.setMnemonic('N');
|
nextButton.setMnemonic('N');
|
||||||
nextButton.setDisplayedMnemonicIndex(0);
|
|
||||||
nextButton.addActionListener(e -> playNextSong());
|
nextButton.addActionListener(e -> playNextSong());
|
||||||
toolBar.add(nextButton);
|
controlBar.add(nextButton);
|
||||||
|
toolBar.add(controlBar);
|
||||||
toolBar.add(createVolumeControls());
|
toolBar.add(createVolumeControls());
|
||||||
return toolBar;
|
return toolBar;
|
||||||
}
|
}
|
||||||
@ -489,6 +499,32 @@ public class PlayerGUI implements PlayerCallbackInterface, LibraryCallbackInterf
|
|||||||
|
|
||||||
// Add everything to the menu bar itself
|
// Add everything to the menu bar itself
|
||||||
menuBar.add(playlistTools);
|
menuBar.add(playlistTools);
|
||||||
|
|
||||||
|
JMenu helpMenu = new JMenu("Help");
|
||||||
|
menuItem = new JMenuItem("About");
|
||||||
|
menuItem.addActionListener(e -> {
|
||||||
|
try {
|
||||||
|
//noinspection ConstantConditions
|
||||||
|
JEditorPane messagePane = new JEditorPane("text/html", Files.readAllLines(
|
||||||
|
Paths.get(PlayerGUI.class.getClassLoader().getResource("LICENSE.txt").toURI())).get(0));
|
||||||
|
messagePane.setEditable(false);
|
||||||
|
messagePane.addHyperlinkListener(hl -> {
|
||||||
|
if (hl.getEventType() == HyperlinkEvent.EventType.ACTIVATED)
|
||||||
|
if(Desktop.isDesktopSupported())
|
||||||
|
try {
|
||||||
|
Desktop.getDesktop().browse(hl.getURL().toURI());
|
||||||
|
} catch (IOException | URISyntaxException e1) {
|
||||||
|
e1.printStackTrace();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
JOptionPane.showMessageDialog(mainPanel, messagePane, "About", JOptionPane.INFORMATION_MESSAGE);
|
||||||
|
} catch (IOException | URISyntaxException e1) {
|
||||||
|
e1.printStackTrace();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
helpMenu.add(menuItem);
|
||||||
|
|
||||||
|
menuBar.add(helpMenu);
|
||||||
return menuBar;
|
return menuBar;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
14
src/main/java/musicplayer/util/Icons.java
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
package musicplayer.util;
|
||||||
|
|
||||||
|
import javax.swing.*;
|
||||||
|
|
||||||
|
@SuppressWarnings("ConstantConditions")
|
||||||
|
public final class Icons {
|
||||||
|
|
||||||
|
private static final ClassLoader classLoader = Icons.class.getClassLoader();
|
||||||
|
public static final Icon playIcon = new ImageIcon(classLoader.getResource("glyphicons-174-play.png"));
|
||||||
|
public static final Icon pauseIcon = new ImageIcon(classLoader.getResource("glyphicons-175-pause.png"));
|
||||||
|
public static final Icon stopIcon = new ImageIcon(classLoader.getResource("glyphicons-176-stop.png"));
|
||||||
|
public static final Icon prevIcon = new ImageIcon(classLoader.getResource("glyphicons-171-step-backward.png"));
|
||||||
|
public static final Icon nextIcon = new ImageIcon(classLoader.getResource("glyphicons-179-step-forward.png"));
|
||||||
|
}
|
2
src/main/resources/LICENSE.txt
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
<html><a href="http://glyphicons.com/">GLYPHICONS FREE by Jan Kovarik</a> is licensed under <a href="http://creativecommons.org/licenses/by/3.0/">CC BY 3.0</a>.
|
||||||
|
</html>
|
BIN
src/main/resources/glyphicons-171-step-backward.png
Normal file
After Width: | Height: | Size: 1.2 KiB |
BIN
src/main/resources/glyphicons-172-fast-backward.png
Normal file
After Width: | Height: | Size: 1.3 KiB |
BIN
src/main/resources/glyphicons-173-rewind.png
Normal file
After Width: | Height: | Size: 1.3 KiB |
BIN
src/main/resources/glyphicons-174-play.png
Normal file
After Width: | Height: | Size: 1.2 KiB |
BIN
src/main/resources/glyphicons-175-pause.png
Normal file
After Width: | Height: | Size: 1.2 KiB |
BIN
src/main/resources/glyphicons-176-stop.png
Normal file
After Width: | Height: | Size: 1.2 KiB |
BIN
src/main/resources/glyphicons-177-forward.png
Normal file
After Width: | Height: | Size: 1.3 KiB |
BIN
src/main/resources/glyphicons-178-fast-forward.png
Normal file
After Width: | Height: | Size: 1.3 KiB |
BIN
src/main/resources/glyphicons-179-step-forward.png
Normal file
After Width: | Height: | Size: 1.2 KiB |