Mau sharing nih gimana buat MP3 Player dari Netbeans . simak yaaa..... ;)
*Eeeeiitts!!! Jika ingin menambah icon-icon atau gambar, jangan lupa disimpan didalam satu folder yang program kalian kerjakan , mis. nama folder Tugas 3 jadi icon-icon nya diletakkan di folder itu.*
Dibawah ini adalah coding nya :
package Praktek3;
import java.io.File;
import java.net.URL;
import javax.media.Manager;
import javax.media.Player;
import javax.swing.DefaultListModel;
import javax.swing.JFileChooser;
import javax.swing.JFrame;
/**
*
* @author user
*/
public class Lagu extends javax.swing.JFrame {
DefaultListModel model = new DefaultListModel();
public Player mp3;
/**
* Creates new form Lagu
*/
public Lagu() {
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")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
jPanel1 = new javax.swing.JPanel();
jLabel1 = new javax.swing.JLabel();
jButton1 = new javax.swing.JButton();
jButton2 = new javax.swing.JButton();
jScrollPane1 = new javax.swing.JScrollPane();
jList1 = new javax.swing.JList();
jButton3 = new javax.swing.JButton();
jLabel2 = new javax.swing.JLabel();
jLabel3 = new javax.swing.JLabel();
jLabel4 = new javax.swing.JLabel();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
jPanel1.setBackground(new java.awt.Color(255, 153, 204));
jLabel1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Praktek3/MP3 File.png"))); // NOI18N
jButton1.setBackground(new java.awt.Color(255, 255, 255));
jButton1.setFont(new java.awt.Font("Tw Cen MT", 0, 18)); // NOI18N
jButton1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Praktek3/33 edit.png"))); // NOI18N
jButton1.setText("Add Playlist");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});
jButton2.setBackground(new java.awt.Color(255, 255, 255));
jButton2.setFont(new java.awt.Font("Tw Cen MT", 0, 18)); // NOI18N
jButton2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Praktek3/icon_small_cross.gif"))); // NOI18N
jButton2.setText("Delete List");
jButton2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton2ActionPerformed(evt);
}
});
jScrollPane1.setViewportView(jList1);
jButton3.setBackground(new java.awt.Color(204, 204, 204));
jButton3.setFont(new java.awt.Font("Tw Cen MT", 0, 18)); // NOI18N
jButton3.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Praktek3/23 edit.gif"))); // NOI18N
jButton3.setText("Play");
jButton3.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton3ActionPerformed(evt);
}
});
jLabel2.setFont(new java.awt.Font("SL Runaway Girl", 0, 48)); // NOI18N
jLabel2.setText("Playlist");
jLabel3.setFont(new java.awt.Font("Batman Beat the hell Outta Me", 0, 36)); // NOI18N
jLabel3.setText("Music Player");
javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel4, javax.swing.GroupLayout.Alignment.TRAILING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
.addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 121, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(30, 30, 30)
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(32, 32, 32))))
.addGroup(jPanel1Layout.createSequentialGroup()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(65, 65, 65)
.addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 176, javax.swing.GroupLayout.PREFERRED_SIZE)