diff --git a/build.xml b/build.xml new file mode 100644 index 0000000..ce9d744 --- /dev/null +++ b/build.xml @@ -0,0 +1,73 @@ + + + + + + + + + + + Builds, tests, and runs the project MusicPlayer. + + + diff --git a/build/classes/.netbeans_automatic_build b/build/classes/.netbeans_automatic_build new file mode 100644 index 0000000..e69de29 diff --git a/build/classes/.netbeans_update_resources b/build/classes/.netbeans_update_resources new file mode 100644 index 0000000..e69de29 diff --git a/build/classes/Application/Application$ThreadPlayer.class b/build/classes/Application/Application$ThreadPlayer.class new file mode 100644 index 0000000..518b068 Binary files /dev/null and b/build/classes/Application/Application$ThreadPlayer.class differ diff --git a/build/classes/Application/Application.class b/build/classes/Application/Application.class new file mode 100644 index 0000000..bd3d5ca Binary files /dev/null and b/build/classes/Application/Application.class differ diff --git a/build/classes/Controller/Controller.class b/build/classes/Controller/Controller.class new file mode 100644 index 0000000..9762637 Binary files /dev/null and b/build/classes/Controller/Controller.class differ diff --git a/build/classes/Driver/Driver.class b/build/classes/Driver/Driver.class new file mode 100644 index 0000000..84f58ff Binary files /dev/null and b/build/classes/Driver/Driver.class differ diff --git a/build/classes/PlayerGui/PlayerGui$1.class b/build/classes/PlayerGui/PlayerGui$1.class new file mode 100644 index 0000000..dc0024e Binary files /dev/null and b/build/classes/PlayerGui/PlayerGui$1.class differ diff --git a/build/classes/PlayerGui/PlayerGui$2.class b/build/classes/PlayerGui/PlayerGui$2.class new file mode 100644 index 0000000..6cfe54a Binary files /dev/null and b/build/classes/PlayerGui/PlayerGui$2.class differ diff --git a/build/classes/PlayerGui/PlayerGui$3.class b/build/classes/PlayerGui/PlayerGui$3.class new file mode 100644 index 0000000..d0279f8 Binary files /dev/null and b/build/classes/PlayerGui/PlayerGui$3.class differ diff --git a/build/classes/PlayerGui/PlayerGui$4.class b/build/classes/PlayerGui/PlayerGui$4.class new file mode 100644 index 0000000..3b455d1 Binary files /dev/null and b/build/classes/PlayerGui/PlayerGui$4.class differ diff --git a/build/classes/PlayerGui/PlayerGui$5.class b/build/classes/PlayerGui/PlayerGui$5.class new file mode 100644 index 0000000..961ff34 Binary files /dev/null and b/build/classes/PlayerGui/PlayerGui$5.class differ diff --git a/build/classes/PlayerGui/PlayerGui$6.class b/build/classes/PlayerGui/PlayerGui$6.class new file mode 100644 index 0000000..b24245c Binary files /dev/null and b/build/classes/PlayerGui/PlayerGui$6.class differ diff --git a/build/classes/PlayerGui/PlayerGui$7.class b/build/classes/PlayerGui/PlayerGui$7.class new file mode 100644 index 0000000..e245efc Binary files /dev/null and b/build/classes/PlayerGui/PlayerGui$7.class differ diff --git a/build/classes/PlayerGui/PlayerGui.class b/build/classes/PlayerGui/PlayerGui.class new file mode 100644 index 0000000..f8bb596 Binary files /dev/null and b/build/classes/PlayerGui/PlayerGui.class differ diff --git a/build/classes/PlayerGui/PlayerGui.form b/build/classes/PlayerGui/PlayerGui.form new file mode 100644 index 0000000..200debd --- /dev/null +++ b/build/classes/PlayerGui/PlayerGui.form @@ -0,0 +1,165 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
diff --git a/manifest.mf b/manifest.mf new file mode 100644 index 0000000..328e8e5 --- /dev/null +++ b/manifest.mf @@ -0,0 +1,3 @@ +Manifest-Version: 1.0 +X-COMMENT: Main-Class will be added automatically by build + diff --git a/nbproject/build-impl.xml b/nbproject/build-impl.xml new file mode 100644 index 0000000..0ae0aee --- /dev/null +++ b/nbproject/build-impl.xml @@ -0,0 +1,1420 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set src.dir + Must set test.src.dir + Must set build.dir + Must set dist.dir + Must set build.classes.dir + Must set dist.javadoc.dir + Must set build.test.classes.dir + Must set build.test.results.dir + Must set build.classes.excludes + Must set dist.jar + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set javac.includes + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + No tests executed. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set JVM to use for profiling in profiler.info.jvm + Must set profiler agent JVM arguments in profiler.info.jvmargs.agent + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select some files in the IDE or set javac.includes + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + To run this application from the command line without Ant, try: + + java -jar "${dist.jar.resolved}" + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select one file in the IDE or set run.class + + + + Must select one file in the IDE or set run.class + + + + + + + + + + + + + + + + + + + + + + + Must select one file in the IDE or set debug.class + + + + + Must select one file in the IDE or set debug.class + + + + + Must set fix.includes + + + + + + + + + + This target only works when run from inside the NetBeans IDE. + + + + + + + + + Must select one file in the IDE or set profile.class + This target only works when run from inside the NetBeans IDE. + + + + + + + + + This target only works when run from inside the NetBeans IDE. + + + + + + + + + + + + + This target only works when run from inside the NetBeans IDE. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select one file in the IDE or set run.class + + + + + + Must select some files in the IDE or set test.includes + + + + + Must select one file in the IDE or set run.class + + + + + Must select one file in the IDE or set applet.url + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select some files in the IDE or set javac.includes + + + + + + + + + + + + + + + + + + + + Some tests failed; see details above. + + + + + + + + + Must select some files in the IDE or set test.includes + + + + Some tests failed; see details above. + + + + Must select some files in the IDE or set test.class + Must select some method in the IDE or set test.method + + + + Some tests failed; see details above. + + + + + Must select one file in the IDE or set test.class + + + + Must select one file in the IDE or set test.class + Must select some method in the IDE or set test.method + + + + + + + + + + + + + + Must select one file in the IDE or set applet.url + + + + + + + + + Must select one file in the IDE or set applet.url + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/nbproject/genfiles.properties b/nbproject/genfiles.properties new file mode 100644 index 0000000..237ce34 --- /dev/null +++ b/nbproject/genfiles.properties @@ -0,0 +1,8 @@ +build.xml.data.CRC32=6ea9cd52 +build.xml.script.CRC32=1fe043b5 +build.xml.stylesheet.CRC32=8064a381@1.80.1.48 +# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. +# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. +nbproject/build-impl.xml.data.CRC32=6ea9cd52 +nbproject/build-impl.xml.script.CRC32=dad7de4f +nbproject/build-impl.xml.stylesheet.CRC32=830a3534@1.80.1.48 diff --git a/nbproject/private/private.properties b/nbproject/private/private.properties new file mode 100644 index 0000000..15f91d6 --- /dev/null +++ b/nbproject/private/private.properties @@ -0,0 +1,2 @@ +compile.on.save=true +user.properties.file=C:\\Users\\Geb\\AppData\\Roaming\\NetBeans\\8.2\\build.properties diff --git a/nbproject/private/private.xml b/nbproject/private/private.xml new file mode 100644 index 0000000..da00b31 --- /dev/null +++ b/nbproject/private/private.xml @@ -0,0 +1,12 @@ + + + + + + file:/E:/Kuliah/PBO/Task_5/MusicPlayer/src/Application/Application.java + file:/E:/Kuliah/PBO/Task_5/MusicPlayer/src/Driver/Driver.java + file:/E:/Kuliah/PBO/Task_5/MusicPlayer/src/Controller/Controller.java + file:/E:/Kuliah/PBO/Task_5/MusicPlayer/src/PlayerGui/PlayerGui.java + + + diff --git a/nbproject/project.properties b/nbproject/project.properties new file mode 100644 index 0000000..943011c --- /dev/null +++ b/nbproject/project.properties @@ -0,0 +1,75 @@ +annotation.processing.enabled=true +annotation.processing.enabled.in.editor=false +annotation.processing.processor.options= +annotation.processing.processors.list= +annotation.processing.run.all.processors=true +annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output +build.classes.dir=${build.dir}/classes +build.classes.excludes=**/*.java,**/*.form +# This directory is removed when the project is cleaned: +build.dir=build +build.generated.dir=${build.dir}/generated +build.generated.sources.dir=${build.dir}/generated-sources +# Only compile against the classpath explicitly listed here: +build.sysclasspath=ignore +build.test.classes.dir=${build.dir}/test/classes +build.test.results.dir=${build.dir}/test/results +# Uncomment to specify the preferred debugger connection transport: +#debug.transport=dt_socket +debug.classpath=\ + ${run.classpath} +debug.test.classpath=\ + ${run.test.classpath} +# Files in build.classes.dir which should be excluded from distribution jar +dist.archive.excludes= +# This directory is removed when the project is cleaned: +dist.dir=dist +dist.jar=${dist.dir}/MusicPlayer.jar +dist.javadoc.dir=${dist.dir}/javadoc +excludes= +includes=** +jar.compress=false +javac.classpath=\ + ${libs.jlayer.classpath} +# Space-separated list of extra javac options +javac.compilerargs= +javac.deprecation=false +javac.external.vm=true +javac.processorpath=\ + ${javac.classpath} +javac.source=1.8 +javac.target=1.8 +javac.test.classpath=\ + ${javac.classpath}:\ + ${build.classes.dir} +javac.test.processorpath=\ + ${javac.test.classpath} +javadoc.additionalparam= +javadoc.author=false +javadoc.encoding=${source.encoding} +javadoc.noindex=false +javadoc.nonavbar=false +javadoc.notree=false +javadoc.private=false +javadoc.splitindex=true +javadoc.use=true +javadoc.version=false +javadoc.windowtitle= +main.class= +manifest.file=manifest.mf +meta.inf.dir=${src.dir}/META-INF +mkdist.disabled=false +platform.active=default_platform +run.classpath=\ + ${javac.classpath}:\ + ${build.classes.dir} +# Space-separated list of JVM arguments used when running the project. +# You may also define separate properties like run-sys-prop.name=value instead of -Dname=value. +# To set system properties for unit tests define test-sys-prop.name=value: +run.jvmargs= +run.test.classpath=\ + ${javac.test.classpath}:\ + ${build.test.classes.dir} +source.encoding=UTF-8 +src.dir=src +test.src.dir=test diff --git a/nbproject/project.xml b/nbproject/project.xml new file mode 100644 index 0000000..858374d --- /dev/null +++ b/nbproject/project.xml @@ -0,0 +1,15 @@ + + + org.netbeans.modules.java.j2seproject + + + MusicPlayer + + + + + + + + + diff --git a/src/Application/Application.java b/src/Application/Application.java new file mode 100644 index 0000000..6b10cd7 --- /dev/null +++ b/src/Application/Application.java @@ -0,0 +1,91 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package Application; + + +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.util.ArrayList; +import javazoom.jl.decoder.JavaLayerException; +import javazoom.jl.player.Player; +/** + * + * @author Geb + */ +public class Application { + private ArrayList musicList; + private ThreadPlayer thread; + private int nowPlaying; + + public Application () { + musicList = new ArrayList (); + } + + public void addMusic (String path) { + musicList.add(path); + } + + public String [] getMusicList() { + return (String[]) musicList.toArray(new String[0]); + } + + public String getNowPlayed() { + return musicList.get(nowPlaying); + } + + public void removeMusic(int i) { + musicList.remove(i); + } + + public void play(int i) { + nowPlaying = i; + String filepath = musicList.get(i); + thread = new ThreadPlayer(filepath); + thread.start(); + } + + public void stop() { + if (thread != null) { + thread.stop(); + } + } + + public void next() { + if (nowPlaying < musicList.size() - 1){ + stop(); + play(nowPlaying + 1); + } + } + + public void prev() { + if (nowPlaying < musicList.size() + 1){ + stop(); + play(nowPlaying - 1); + } + } + + public class ThreadPlayer extends Thread { + private String filepath; + private Player player; + + public ThreadPlayer (String filepath) { + this.filepath = filepath; + } + + public void run() { + try { + FileInputStream fis = new FileInputStream(filepath); + player = new Player(fis); + player.play(); + } catch (FileNotFoundException exc) { + throw new IllegalStateException ("File "+ filepath + " not found"); + } catch (JavaLayerException exc) { + throw new IllegalStateException ("ERROR while file "); + } + } + } + +} diff --git a/src/Controller/Controller.java b/src/Controller/Controller.java new file mode 100644 index 0000000..ea0cbcd --- /dev/null +++ b/src/Controller/Controller.java @@ -0,0 +1,78 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package Controller; + +import Application.Application; +import PlayerGui.PlayerGui; +import java.awt.HeadlessException; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import javax.swing.JFileChooser; +import javax.swing.JOptionPane; +import javax.swing.filechooser.FileNameExtensionFilter; + +/** + * + * @author Geb + */ +public class Controller implements ActionListener{ + private Application app; + private PlayerGui view; + + public Controller() { + app = new Application(); + view = new PlayerGui(); + view.setVisible(true); + view.addListener(this); + view.setListMusic(app.getMusicList()); + } + + public void actionPerformed(ActionEvent ae) { + Object source = ae.getSource(); + + try { + if (source.equals(view.getBtnAdd())) { + JFileChooser fc = new JFileChooser(); + FileNameExtensionFilter filter = new FileNameExtensionFilter ("MP3 Filed", "mp3", "mp3"); + fc.setFileFilter(filter); + int returnVal = fc.showOpenDialog(view); + + + if (returnVal == JFileChooser.APPROVE_OPTION) { + String path = fc.getSelectedFile().getAbsolutePath(); + app.addMusic(path); + view.setListMusic(app.getMusicList()); + } + + }else if (source.equals(view.getBtnDelete())) { + int selected = view.getSelectedMusic(); + app.removeMusic(selected); + view.setListMusic(app.getMusicList()); + + }else if (source.equals(view.getBtnPlay())) { + int selected = view.getSelectedMusic(); + app.stop(); + app.play(selected); + view.setTxFieldPlaying(app.getNowPlayed()); + + }else if (source.equals(view.getBtnStop())) { + app.stop(); + view.setTxFieldPlaying(""); + + }else if (source.equals(view.getBtnNext())) { + app.next(); + view.setTxFieldPlaying(app.getNowPlayed()); + + }else if (source.equals(view.getBtnPrev())) { + app.prev(); + view.setTxFieldPlaying(app.getNowPlayed()); + } + } catch (Exception e) { + JOptionPane.showMessageDialog(view, e.getMessage()); + } +} +} + diff --git a/src/Driver/Driver.java b/src/Driver/Driver.java new file mode 100644 index 0000000..2137144 --- /dev/null +++ b/src/Driver/Driver.java @@ -0,0 +1,19 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package Driver; + +import Controller.Controller; + + +/** + * + * @author Geb + */ +public class Driver { + public static void main(String[] args) { + Controller c = new Controller(); + } +} diff --git a/src/PlayerGui/PlayerGui.form b/src/PlayerGui/PlayerGui.form new file mode 100644 index 0000000..200debd --- /dev/null +++ b/src/PlayerGui/PlayerGui.form @@ -0,0 +1,165 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
diff --git a/src/PlayerGui/PlayerGui.java b/src/PlayerGui/PlayerGui.java new file mode 100644 index 0000000..737fc58 --- /dev/null +++ b/src/PlayerGui/PlayerGui.java @@ -0,0 +1,237 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package PlayerGui; + +import java.awt.event.ActionListener; + +/** + * + * @author Geb + */ +public class PlayerGui extends javax.swing.JFrame { + + /** + * Creates new form GUI + */ + public PlayerGui() { + initComponents(); + } + + /** + * This method is called from within the constructor to initialize the form. + * WARNING: Do NOT modify this code. The content of this method is always + * regenerated by the Form Editor. + */ + @SuppressWarnings("unchecked") + // //GEN-BEGIN:initComponents + private void initComponents() { + + jScrollPane1 = new javax.swing.JScrollPane(); + listMusic = new javax.swing.JList<>(); + jLabel1 = new javax.swing.JLabel(); + txFieldPlaying = new javax.swing.JTextField(); + btnAdd = new javax.swing.JButton(); + btnDelete = new javax.swing.JButton(); + btnPrev = new javax.swing.JButton(); + btnPlay = new javax.swing.JButton(); + btnStop = new javax.swing.JButton(); + btnNext = new javax.swing.JButton(); + + setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); + + listMusic.setModel(new javax.swing.AbstractListModel() { + String[] strings = { "Item 1", "Item 2", "Item 3", "Item 4", "Item 5" }; + public int getSize() { return strings.length; } + public String getElementAt(int i) { return strings[i]; } + }); + jScrollPane1.setViewportView(listMusic); + + jLabel1.setText("Now Playing"); + + txFieldPlaying.setEditable(false); + txFieldPlaying.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + txFieldPlayingActionPerformed(evt); + } + }); + + btnAdd.setText("Add"); + + btnDelete.setText("Delete"); + btnDelete.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + btnDeleteActionPerformed(evt); + } + }); + + btnPrev.setText("<<"); + btnPrev.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + btnPrevActionPerformed(evt); + } + }); + + btnPlay.setText("Play"); + btnPlay.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + btnPlayActionPerformed(evt); + } + }); + + btnStop.setText("Stop"); + btnStop.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + btnStopActionPerformed(evt); + } + }); + + btnNext.setText(">>"); + btnNext.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + btnNextActionPerformed(evt); + } + }); + + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); + getContentPane().setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jScrollPane1) + .addGroup(layout.createSequentialGroup() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false) + .addComponent(btnAdd, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(jLabel1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + .addGap(18, 18, 18) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(txFieldPlaying) + .addGroup(layout.createSequentialGroup() + .addComponent(btnDelete) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(btnPrev) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(btnPlay) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(btnStop) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 20, Short.MAX_VALUE) + .addComponent(btnNext))))) + .addContainerGap()) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(18, 18, 18) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel1) + .addComponent(txFieldPlaying, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGap(18, 18, 18) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(btnAdd) + .addComponent(btnDelete) + .addComponent(btnPrev) + .addComponent(btnPlay) + .addComponent(btnStop) + .addComponent(btnNext)) + .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + ); + + pack(); + }// //GEN-END:initComponents + + private void txFieldPlayingActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txFieldPlayingActionPerformed + // TODO add your handling code here: + }//GEN-LAST:event_txFieldPlayingActionPerformed + + private void btnDeleteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnDeleteActionPerformed + // TODO add your handling code here: + }//GEN-LAST:event_btnDeleteActionPerformed + + private void btnPrevActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnPrevActionPerformed + // TODO add your handling code here: + }//GEN-LAST:event_btnPrevActionPerformed + + private void btnPlayActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnPlayActionPerformed + // TODO add your handling code here: + }//GEN-LAST:event_btnPlayActionPerformed + + private void btnStopActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnStopActionPerformed + // TODO add your handling code here: + }//GEN-LAST:event_btnStopActionPerformed + + private void btnNextActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnNextActionPerformed + // TODO add your handling code here: + }//GEN-LAST:event_btnNextActionPerformed + + /** + * @param args the command line arguments + */ + + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JButton btnAdd; + private javax.swing.JButton btnDelete; + private javax.swing.JButton btnNext; + private javax.swing.JButton btnPlay; + private javax.swing.JButton btnPrev; + private javax.swing.JButton btnStop; + private javax.swing.JLabel jLabel1; + private javax.swing.JScrollPane jScrollPane1; + private javax.swing.JList listMusic; + private javax.swing.JTextField txFieldPlaying; + // End of variables declaration//GEN-END:variables + + public Object getBtnAdd(){ + return btnAdd; + } + + public Object getBtnDelete(){ + return btnDelete; + } + + public Object getBtnNext(){ + return btnNext; + } + + public Object getBtnPlay(){ + return btnPlay; + } + + public Object getBtnPrev(){ + return btnPrev; + } + + public Object getBtnStop(){ + return btnStop; + } + + public void setListMusic(String [] musicList){ + listMusic.setListData(musicList); + } + + public void setTxFieldPlaying(String filename){ + txFieldPlaying.setText(filename); + } + + public int getSelectedMusic(){ + if (listMusic.getSelectedIndex() == -1) { + throw new IllegalStateException("Please select any music"); + } + return listMusic.getSelectedIndex(); + } + public void addListener(ActionListener e){ + btnAdd.addActionListener (e); + btnDelete.addActionListener (e); + btnNext.addActionListener (e); + btnPlay.addActionListener (e); + btnPrev.addActionListener (e); + btnStop.addActionListener(e); + } +} +