My project is an MP3 Player and in a table you are given the location of an MP3 file. I have the play/pause/stop/fastforward/re-wind buttons ready.
Each time you select a different row from the table, I need to be able to take a field from that row and create an instance of a class that “controls” the MP3. Also, I need the different control buttons to access the same instance of that class.
For example:
- Select Row 5
- Get “location” field value
- create an instance of a class that controls the MP3
- Allow the buttons to access the same instance of the class
And if you wanted to play another MP3, you would just need to select another row from the table and press play.
The code for the ActionListeners of your button would need to reference the table directly. For example the code for your “Play” button might be something like:
Now that you know the file you want to play you invoke the code for your MP3 player.
Most of your other actions (Stop, Rewind…) would then act on your MP3 player.