Sei sulla pagina 1di 19

INSTITUTO TECNOLGICO DE MATEHUALA (ITMH) IVAN ASAEL PEA MENDOZA. IRMA KARINA VEGA. ORGANIZACIN DE DATOS. PROYECTO FINAL.

- REPRODUCTOR. CUARTO SEMESTRE. LICENCIADO EN INFORMTICA. ING. LUCIANO CONTRERAS QUINTERO.

INDICE:
OBJETIVO. INTRODUCCIN. UMLS. CDIGOS. CORRIDA. CONCLUSIONES.

OBJETIVO:
El alumno aprender a utilizar el uso de archivos secuenciales con JList, para que estos tengan una funcin excelente. El alumno deber construir la interfaz y el cdigo para que al momento de seleccionar un ndice de la lista este muestre el gener, la cancin, una imagen del artista y reproduzca la cancin.

En este proyecto se trabajar con archivos secuenciales, para poder trabajar y colocar el nombre de los artistas en un archivo y en el otro el nombre de los artistas, para que estos se puedan cargar con un botn que en la interfaz fue creado, as que cuando se le d clic a ese botn, pueda cargar el nombre de los artistas y canciones. Tambin se estar hablando y se utilizara JList y lisModel, para la seleccin de la lista, tambin las clases para poder cargar audio y reproducirlo. Al momento de seleccionas un elemento de la lista, est seleccione la cancin y el gener, adems de que muestre la imagen del artista y la cancin que tiene. Eso es lo que se desea alcanzar para lograr un buen desarrollo de este proyecto. Por medio de la interfaz ya realizada se mostrara de manera grfica y podr el usuario trabajar con ella al momento de ser corrida.

INTRODUCCIN:

DESARROLLO:
UML DE LA CLASE ProyectoFinalView:
ProyectoFinalView

+ProyectoFinalView(app: SingleFrameApplication ) -jList1ValueChanged(javax.swing.event.ListSelectionEvent: evt) void -private void -jButton3ActionPerformed(evt: java.awt.event.ActionEvent) void -jButton2ActionPerformed(evt: java.awt.event.ActionEvent): void

CDIGO DE LA CLASE ProyectoFinalView:

package proyectofinal;//Nombre del paquete. import org.jdesktop.application.Action;//De la lnea de 2 a 6, importa los paquetes para la aplicacin grfica. import org.jdesktop.application.ResourceMap; import org.jdesktop.application.SingleFrameApplication; import org.jdesktop.application.FrameView; import org.jdesktop.application.TaskMonitor; import javax.swing.*;//Importa la paquetera swing conpleta. import java.awt.event.ActionListener;//Importa la paquetera .awt. import java.io.*;//Importa la paqueteria .io. import javax.swing.Icon;//Importacin del javax.swing. import java.awt.event.ActionEvent; /** * The application's main frame. */ public class ProyectoFinalView extends FrameView {//Nombre de la clase. private DefaultListModel listModel;//Declaracin de la lista de modelo 1. private DefaultListModel listModel2;//Declaracin de la lista de modelo 2. public ProyectoFinalView(SingleFrameApplication app) { super(app); initComponents(); // status bar initialization - message timeout, idle icon and busy animation, etc ResourceMap resourceMap = getResourceMap(); int messageTimeout = resourceMap.getInteger("StatusBar.messageTimeout"); messageTimer = new Timer(messageTimeout, new ActionListener() { public void actionPerformed(ActionEvent e) { statusMessageLabel.setText(""); } }); messageTimer.setRepeats(false); int busyAnimationRate = resourceMap.getInteger("StatusBar.busyAnimationRate"); for (int i = 0; i < busyIcons.length; i++) { busyIcons[i] = resourceMap.getIcon("StatusBar.busyIcons[" + i + "]"); } busyIconTimer = new Timer(busyAnimationRate, new ActionListener() { public void actionPerformed(ActionEvent e) { busyIconIndex = (busyIconIndex + 1) % busyIcons.length; statusAnimationLabel.setIcon(busyIcons[busyIconIndex]); } });

idleIcon = resourceMap.getIcon("StatusBar.idleIcon"); statusAnimationLabel.setIcon(idleIcon); progressBar.setVisible(false); // connecting action tasks to status bar via TaskMonitor TaskMonitor taskMonitor = new TaskMonitor(getApplication().getContext()); taskMonitor.addPropertyChangeListener(new java.beans.PropertyChangeListener() { public void propertyChange(java.beans.PropertyChangeEvent evt) { String propertyName = evt.getPropertyName(); if ("started".equals(propertyName)) { if (!busyIconTimer.isRunning()) { statusAnimationLabel.setIcon(busyIcons[0]); busyIconIndex = 0; busyIconTimer.start(); } progressBar.setVisible(true); progressBar.setIndeterminate(true); } else if ("done".equals(propertyName)) { busyIconTimer.stop(); statusAnimationLabel.setIcon(idleIcon); progressBar.setVisible(false); progressBar.setValue(0); } else if ("message".equals(propertyName)) { String text = (String)(evt.getNewValue()); statusMessageLabel.setText((text == null) ? "" : text); messageTimer.restart(); } else if ("progress".equals(propertyName)) { int value = (Integer)(evt.getNewValue()); progressBar.setVisible(true); progressBar.setIndeterminate(false); progressBar.setValue(value); } } }); }//Nombre del constructor y su funcionamiento y declaracin. @Action public void showAboutBox() { if (aboutBox == null) { JFrame mainFrame = ProyectoFinalApp.getApplication().getMainFrame(); aboutBox = new ProyectoFinalAboutBox(mainFrame); aboutBox.setLocationRelativeTo(mainFrame); } ProyectoFinalApp.getApplication().show(aboutBox); } /** 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() { mainPanel = new javax.swing.JPanel(); jLabel1 = new javax.swing.JLabel(); jLabel2 = new javax.swing.JLabel(); jLabel3 = new javax.swing.JLabel(); jLabel4 = new javax.swing.JLabel(); jScrollPane1 = new javax.swing.JScrollPane(); jList1 = new javax.swing.JList(); jScrollPane2 = new javax.swing.JScrollPane(); jList2 = new javax.swing.JList(); jScrollPane3 = new javax.swing.JScrollPane(); jList3 = new javax.swing.JList(); jLabel5 = new javax.swing.JLabel();

jButton2 = new javax.swing.JButton(); jButton3 = new javax.swing.JButton(); menuBar = new javax.swing.JMenuBar(); javax.swing.JMenu fileMenu = new javax.swing.JMenu(); javax.swing.JMenuItem exitMenuItem = new javax.swing.JMenuItem(); javax.swing.JMenu helpMenu = new javax.swing.JMenu(); javax.swing.JMenuItem aboutMenuItem = new javax.swing.JMenuItem(); statusPanel = new javax.swing.JPanel(); javax.swing.JSeparator statusPanelSeparator = new javax.swing.JSeparator(); statusMessageLabel = new javax.swing.JLabel(); statusAnimationLabel = new javax.swing.JLabel(); progressBar = new javax.swing.JProgressBar(); mainPanel.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR)); mainPanel.setName("mainPanel"); // NOI18N org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(proyectofinal.ProyectoFinalApp.class).getContext().getResourceMap(ProyectoFinalView.clas s); jLabel1.setFont(resourceMap.getFont("jLabel1.font")); // NOI18N jLabel1.setName("jLabel1"); // NOI18N jLabel2.setFont(resourceMap.getFont("jLabel3.font")); // NOI18N jLabel2.setText(resourceMap.getString("jLabel2.text")); // NOI18N jLabel2.setName("jLabel2"); // NOI18N jLabel3.setFont(resourceMap.getFont("jLabel3.font")); // NOI18N jLabel3.setText(resourceMap.getString("jLabel3.text")); // NOI18N jLabel3.setName("jLabel3"); // NOI18N jLabel4.setFont(resourceMap.getFont("jLabel3.font")); // NOI18N jLabel4.setText(resourceMap.getString("jLabel4.text")); // NOI18N jLabel4.setName("jLabel4"); // NOI18N jScrollPane1.setName("jScrollPane1"); // NOI18N jList1.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR)); jList1.setName("jList1"); // NOI18N jList1.addListSelectionListener(new javax.swing.event.ListSelectionListener() { public void valueChanged(javax.swing.event.ListSelectionEvent evt) { jList1ValueChanged(evt); } }); jScrollPane1.setViewportView(jList1); jList1.getAccessibleContext().setAccessibleParent(mainPanel); jScrollPane2.setName("jScrollPane2"); // NOI18N jList2.setModel(new javax.swing.AbstractListModel() { String[] strings = { "POP", "REGGETON", "BANDA", "NORTEA", "DURANGUENSE" }; public int getSize() { return strings.length; } public Object getElementAt(int i) { return strings[i]; } }); jList2.setName("jList2"); // NOI18N jScrollPane2.setViewportView(jList2); jScrollPane3.setName("jScrollPane3"); // NOI18N jList3.setToolTipText(resourceMap.getString("jList3.toolTipText")); // NOI18N jList3.setName("jList3"); // NOI18N jList3.addListSelectionListener(new javax.swing.event.ListSelectionListener() { public void valueChanged(javax.swing.event.ListSelectionEvent evt) { jList3ValueChanged(evt); } }); jScrollPane3.setViewportView(jList3);

jLabel5.setText(resourceMap.getString("jLabel5.text")); // NOI18N jLabel5.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR)); jLabel5.setMaximumSize(new java.awt.Dimension(300, 200)); jLabel5.setName("jLabel5"); // NOI18N jLabel5.addPropertyChangeListener(new java.beans.PropertyChangeListener() { public void propertyChange(java.beans.PropertyChangeEvent evt) { jLabel5PropertyChange(evt); } }); jButton2.setText(resourceMap.getString("jButton2.text")); // NOI18N jButton2.setName("jButton2"); // NOI18N jButton2.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton2ActionPerformed(evt); } }); jButton3.setText(resourceMap.getString("jButton3.text")); // NOI18N jButton3.setName("jButton3"); // NOI18N jButton3.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton3ActionPerformed(evt); } }); javax.swing.GroupLayout mainPanelLayout = new javax.swing.GroupLayout(mainPanel); mainPanel.setLayout(mainPanelLayout); mainPanelLayout.setHorizontalGroup( mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, mainPanelLayout.createSequentialGroup() .addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(mainPanelLayout.createSequentialGroup() .addGap(22, 22, 22) .addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 118, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel2))) .addGroup(mainPanelLayout.createSequentialGroup() .addContainerGap() .addComponent(jButton2))) .addGap(20, 20, 20) .addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(mainPanelLayout.createSequentialGroup() .addGap(37, 37, 37) .addComponent(jLabel1) .addGap(163, 163, 163) .addComponent(jButton3) .addGap(74, 74, 74)) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, mainPanelLayout.createSequentialGroup() .addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jLabel3) .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 118, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGap(39, 39, 39) .addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 118, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel4)) .addGap(43, 43, 43))) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(731, 731, 731)) ); mainPanelLayout.setVerticalGroup( mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addGroup(mainPanelLayout.createSequentialGroup() .addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(mainPanelLayout.createSequentialGroup() .addContainerGap() .addComponent(jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGroup(mainPanelLayout.createSequentialGroup() .addGap(20, 20, 20) .addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, mainPanelLayout.createSequentialGroup() .addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jButton2) .addComponent(jButton3)) .addGap(18, 18, 18) .addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel3) .addComponent(jLabel2) .addComponent(jLabel4))) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, mainPanelLayout.createSequentialGroup() .addComponent(jLabel1) .addGap(60, 60, 60))) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))) .addContainerGap(657, Short.MAX_VALUE)) ); jLabel5.getAccessibleContext().setAccessibleName(resourceMap.getString("jLabel5.AccessibleContext.accessibleName")); // NOI18N menuBar.setName("menuBar"); // NOI18N fileMenu.setText(resourceMap.getString("fileMenu.text")); // NOI18N fileMenu.setName("fileMenu"); // NOI18N javax.swing.ActionMap actionMap = org.jdesktop.application.Application.getInstance(proyectofinal.ProyectoFinalApp.class).getContext().getActionMap(ProyectoFinalView.class, this); exitMenuItem.setAction(actionMap.get("quit")); // NOI18N exitMenuItem.setName("exitMenuItem"); // NOI18N fileMenu.add(exitMenuItem); menuBar.add(fileMenu); helpMenu.setText(resourceMap.getString("helpMenu.text")); // NOI18N helpMenu.setName("helpMenu"); // NOI18N aboutMenuItem.setAction(actionMap.get("showAboutBox")); // NOI18N aboutMenuItem.setName("aboutMenuItem"); // NOI18N helpMenu.add(aboutMenuItem); menuBar.add(helpMenu); statusPanel.setName("statusPanel"); // NOI18N statusPanelSeparator.setName("statusPanelSeparator"); // NOI18N statusMessageLabel.setName("statusMessageLabel"); // NOI18N statusAnimationLabel.setHorizontalAlignment(javax.swing.SwingConstants.LEFT); statusAnimationLabel.setName("statusAnimationLabel"); // NOI18N progressBar.setName("progressBar"); // NOI18N

javax.swing.GroupLayout statusPanelLayout = new javax.swing.GroupLayout(statusPanel); statusPanel.setLayout(statusPanelLayout); statusPanelLayout.setHorizontalGroup( statusPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(statusPanelSeparator, javax.swing.GroupLayout.DEFAULT_SIZE, 1667, Short.MAX_VALUE) .addGroup(statusPanelLayout.createSequentialGroup() .addContainerGap() .addComponent(statusMessageLabel) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 1497, Short.MAX_VALUE) .addComponent(progressBar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(statusAnimationLabel) .addContainerGap()) ); statusPanelLayout.setVerticalGroup( statusPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(statusPanelLayout.createSequentialGroup() .addComponent(statusPanelSeparator, javax.swing.GroupLayout.PREFERRED_SIZE, 2, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGroup(statusPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(statusMessageLabel) .addComponent(statusAnimationLabel) .addComponent(progressBar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGap(3, 3, 3)) ); setComponent(mainPanel); setMenuBar(menuBar); setStatusBar(statusPanel); }// </editor-fold> private void jList1ValueChanged(javax.swing.event.ListSelectionEvent evt) { ResourceMap resourceMap = getResourceMap();//Nombre del mtodo para el JList, y se declara el constrcutor de la clase ResouceMap, para las imagenes. if(jList1.isSelectedIndex(0)){ jList2.setSelectedIndex(0); jList3.setSelectedIndex(0); jLabel5.setIcon(resourceMap.getIcon("jLabel5a.icon")); try {mi_reproductor.AbrirFichero("C:/Users/IVAN/Documents/Proyecto Final/src/proyectofinal/musica/Paulina Rubio Algo De Ti.mp3"); mi_reproductor.Play(); } catch (Exception ex) {}} if(jList1.isSelectedIndex(1)){ jList2.setSelectedIndex(0); jList3.setSelectedIndex(1); jLabel5.setIcon(resourceMap.getIcon("jLabel5b.icon")); try {mi_reproductor.AbrirFichero("C:/Users/IVAN/Documents/Proyecto Final/src/proyectofinal/musica/Shakira Rabiosa ft. Pitbull.mp3"); mi_reproductor.Play(); } catch (Exception ex) {}} if(jList1.isSelectedIndex(2)){ jList2.setSelectedIndex(0); jList3.setSelectedIndex(2); jLabel5.setIcon(resourceMap.getIcon("jLabel5c.icon")); try {mi_reproductor.AbrirFichero("C:/Users/IVAN/Documents/Proyecto Final/src/proyectofinal/musica/Beyonc Run The World (Girls).mp3"); mi_reproductor.Play(); } catch (Exception ex) {}} if(jList1.isSelectedIndex(3)){ jList2.setSelectedIndex(0); jList3.setSelectedIndex(3);

jLabel5.setIcon(resourceMap.getIcon("jLabel5d.icon")); try {mi_reproductor.AbrirFichero("C:/Users/IVAN/Documents/Proyecto Final/src/proyectofinal/musica/Poker Face.mp3"); mi_reproductor.Play(); } catch (Exception ex) {}} if(jList1.isSelectedIndex(4)){ jList2.setSelectedIndex(0); jList3.setSelectedIndex(4); jLabel5.setIcon(resourceMap.getIcon("jLabel5e.icon")); try {mi_reproductor.AbrirFichero("C:/Users/IVAN/Documents/Proyecto Final/src/proyectofinal/musica/umbrella rihana.mp3"); mi_reproductor.Play(); } catch (Exception ex) {}} if(jList1.isSelectedIndex(5)){ jList2.setSelectedIndex(1); jList3.setSelectedIndex(5); jLabel5.setIcon(resourceMap.getIcon("jLabel5f.icon")); try {mi_reproductor.AbrirFichero("C:/Users/IVAN/Documents/Proyecto Final/src/proyectofinal/musica/Daddy_Yankee_Ft._Prince_Royce__Ven_Conmigo.mp3"); mi_reproductor.Play(); } catch (Exception ex) {}} if(jList1.isSelectedIndex(6)){ jList2.setSelectedIndex(1); jList3.setSelectedIndex(6); jLabel5.setIcon(resourceMap.getIcon("jLabel5g.icon")); try {mi_reproductor.AbrirFichero("C:/Users/IVAN/Documents/Proyecto Final/src/proyectofinal/musica/Don Omar & Lucenzo Ft. Daddy Yankee & Arcangel - Danza Kuduro (Official Remix) (Original).mp3"); mi_reproductor.Play(); } catch (Exception ex) {}} if(jList1.isSelectedIndex(7)){ jList2.setSelectedIndex(1); jList3.setSelectedIndex(7); jLabel5.setIcon(resourceMap.getIcon("jLabel5h.icon")); try {mi_reproductor.AbrirFichero("C:/Users/IVAN/Documents/Proyecto Final/src/proyectofinal/musica/estoy enamorado.mp3"); mi_reproductor.Play(); } catch (Exception ex) {}} if(jList1.isSelectedIndex(8)){ jList2.setSelectedIndex(1); jList3.setSelectedIndex(8); jLabel5.setIcon(resourceMap.getIcon("jLabel5i.icon")); try {mi_reproductor.AbrirFichero("C:/Users/IVAN/Documents/Proyecto Final/src/proyectofinal/musica/08_na_de_na_feat_gocho_&_jon_eric_278.mp3"); mi_reproductor.Play(); } catch (Exception ex) {}} if(jList1.isSelectedIndex(9)){ jList2.setSelectedIndex(1); jList3.setSelectedIndex(9); jLabel5.setIcon(resourceMap.getIcon("jLabel5j.icon")); try {mi_reproductor.AbrirFichero("C:/Users/IVAN/Documents/Proyecto Final/src/proyectofinal/musica/tito el bambino - el amor.mp3"); mi_reproductor.Play(); } catch (Exception ex) {}} if(jList1.isSelectedIndex(10)){ jList2.setSelectedIndex(2); jList3.setSelectedIndex(10); jLabel5.setIcon(resourceMap.getIcon("jLabel5k.icon")); try {mi_reproductor.AbrirFichero("C:/Users/IVAN/Documents/Proyecto Final/src/proyectofinal/musica/Banda El Recodo Que Te Ruegue Quien Te Quiera.mp3"); mi_reproductor.Play(); } catch (Exception ex) {}} if(jList1.isSelectedIndex(11)){

jList2.setSelectedIndex(2); jList3.setSelectedIndex(11); jLabel5.setIcon(resourceMap.getIcon("jLabel5l.icon")); try {mi_reproductor.AbrirFichero("C:/Users/IVAN/Documents/Proyecto Final/src/proyectofinal/musica/siempre estas tu la arrolladora banda el limon 2010.mp3"); mi_reproductor.Play(); } catch (Exception ex) {}} if(jList1.isSelectedIndex(12)){ jList2.setSelectedIndex(2); jList3.setSelectedIndex(12); jLabel5.setIcon(resourceMap.getIcon("jLabel5m.icon")); try {mi_reproductor.AbrirFichero("C:/Users/IVAN/Documents/Proyecto Final/src/proyectofinal/musica/Banda Machos Cuatro Meses (Que Se Te Quite Ese Orgullo).mp3"); mi_reproductor.Play(); } catch (Exception ex) {}} if(jList1.isSelectedIndex(13)){ jList2.setSelectedIndex(2); jList3.setSelectedIndex(13); jLabel5.setIcon(resourceMap.getIcon("jLabel5n.icon")); try {mi_reproductor.AbrirFichero("C:/Users/IVAN/Documents/Proyecto Final/src/proyectofinal/musica/al menos.mp3"); mi_reproductor.Play(); } catch (Exception ex) {}} if(jList1.isSelectedIndex(14)){ jList2.setSelectedIndex(2); jList3.setSelectedIndex(14); jLabel5.setIcon(resourceMap.getIcon("jLabel5.icon")); try {mi_reproductor.AbrirFichero("C:/Users/IVAN/Documents/Proyecto Final/src/proyectofinal/musica/el mechon.mp3"); mi_reproductor.Play(); } catch (Exception ex) {}} if(jList1.isSelectedIndex(15)){ jList2.setSelectedIndex(3); jList3.setSelectedIndex(15); jLabel5.setIcon(resourceMap.getIcon("jLabel5o.icon")); try {mi_reproductor.AbrirFichero("C:/Users/IVAN/Documents/Proyecto Final/src/proyectofinal/musica/05 sala de espera(3).mp3"); mi_reproductor.Play(); } catch (Exception ex) {}} if(jList1.isSelectedIndex(16)){ jList2.setSelectedIndex(3); jList3.setSelectedIndex(16); jLabel5.setIcon(resourceMap.getIcon("jLabel5p.icon")); try {mi_reproductor.AbrirFichero("C:/Users/IVAN/Documents/Proyecto Final/src/proyectofinal/musica/belleza de cantina (1)(2).mp3"); mi_reproductor.Play(); } catch (Exception ex) {}} if(jList1.isSelectedIndex(17)){ jList2.setSelectedIndex(3); jList3.setSelectedIndex(17); jLabel5.setIcon(resourceMap.getIcon("jLabel5q.icon")); try {mi_reproductor.AbrirFichero("C:/Users/IVAN/Documents/Proyecto Final/src/proyectofinal/musica/los invasores de nuevo leon - ahora va la mia128.mp3"); mi_reproductor.Play(); } catch (Exception ex) {}} if(jList1.isSelectedIndex(18)){ jList2.setSelectedIndex(3); jList3.setSelectedIndex(18); jLabel5.setIcon(resourceMap.getIcon("jLabel5r.icon")); try {mi_reproductor.AbrirFichero("C:/Users/IVAN/Documents/Proyecto Final/src/proyectofinal/musica/pesado - mientras dormias(2).mp3"); mi_reproductor.Play(); } catch (Exception ex) {}}

if(jList1.isSelectedIndex(19)){ jList2.setSelectedIndex(3); jList3.setSelectedIndex(19); jLabel5.setIcon(resourceMap.getIcon("jLabel5s.icon")); try {mi_reproductor.AbrirFichero("C:/Users/IVAN/Documents/Proyecto Final/src/proyectofinal/musica/01 hay ojitos287.mp3"); mi_reproductor.Play(); } catch (Exception ex) {}} if(jList1.isSelectedIndex(20)){ jList2.setSelectedIndex(4); jList3.setSelectedIndex(20); jLabel5.setIcon(resourceMap.getIcon("jLabel5t.icon")); try {mi_reproductor.AbrirFichero("C:/Users/IVAN/Documents/Proyecto Final/src/proyectofinal/musica/12 la piojosa200.mp3"); mi_reproductor.Play(); } catch (Exception ex) {}} if(jList1.isSelectedIndex(21)){ jList2.setSelectedIndex(4); jList3.setSelectedIndex(21); jLabel5.setIcon(resourceMap.getIcon("jLabel5u.icon")); try {mi_reproductor.AbrirFichero("C:/Users/IVAN/Documents/Proyecto Final/src/proyectofinal/musica/alacranes musical- por amarte asi401.mp3"); mi_reproductor.Play(); } catch (Exception ex) {}} if(jList1.isSelectedIndex(22)){ jList2.setSelectedIndex(4); jList3.setSelectedIndex(22); jLabel5.setIcon(resourceMap.getIcon("jLabel5w.icon")); try {mi_reproductor.AbrirFichero("C:/Users/IVAN/Documents/Proyecto Final/src/proyectofinal/musica/capaz de la sierra la vecinita.mp3"); mi_reproductor.Play(); } catch (Exception ex) {}} if(jList1.isSelectedIndex(23)){ jList2.setSelectedIndex(4); jList3.setSelectedIndex(23); jLabel5.setIcon(resourceMap.getIcon("jLabel5y.icon")); try {mi_reproductor.AbrirFichero("C:/Users/IVAN/Documents/Proyecto Final/src/proyectofinal/musica/los primos de durango - tal vez.mp3"); mi_reproductor.Play(); } catch (Exception ex) {}} if(jList1.isSelectedIndex(24)){ jList2.setSelectedIndex(4); jList3.setSelectedIndex(24); jLabel5.setIcon(resourceMap.getIcon("jLabel5x.icon")); try {mi_reproductor.AbrirFichero("C:/Users/IVAN/Documents/Proyecto Final/src/proyectofinal/musica/patrulla 81 - eres divina.mp3"); mi_reproductor.Play(); } catch (Exception ex) {}} /*EN ESTOS IF LOS CUALES SON 25, LO QUE HACE ES UNA PREGUNTA DE SELECCIN, PARA SELECCIONAR UNA OPCIN QUE ESTE DENTRO DEL INDICE DECLARADO, PARA QUE DE MANERA GRFICA PUEDA SELECCIONARSE Y RELIZAR VARIAS FUNCIONES PARA QUE SE PUEDA TRABAJAR COMODAMENTE.*/ } private void jLabel5PropertyChange(java.beans.PropertyChangeEvent evt) { // TODO add your handling code here: } private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: listModel = new DefaultListModel(); jList1.setModel(listModel); try{ FileInputStream ro= new FileInputStream(a0); DataInputStream ro1= new DataInputStream(ro); ro1 =new DataInputStream(new FileInputStream(a0)); while(true){ String nombre = ro1.readUTF();

listModel.addElement(nombre); }}catch(Exception e){} /*EN ESTE MTODO, MANDA LLAMAR LO QUE ES EL LISTMODEL1, PARA QUE SE PUEDA AL MOMENTO DE SELECCIONAR LA OPCIN QUE TIENE ESTE BOTN PUEDA CARGAR LOS NOMBRES DEL ARCHIVO EL CUAL FUERON METIDOS EL DE LOS ARTISTAS, CON LA LLAMADA DE LA CLASE FIEL LLAMA AL ARCHIVO Y LO MUESTRA EN ESTE BOTN.*/ } private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: listModel2 = new DefaultListModel(); jList3.setModel(listModel2); try{ FileInputStream es= new FileInputStream(a01); DataInputStream te= new DataInputStream(es); te =new DataInputStream(new FileInputStream(a01)); while(true){ String cancion = te.readUTF(); listModel2.addElement(cancion); } }catch(Exception e){} /*EN ESTE OTRO MTODO, MANDA LLAMAR LO QUE ES EL LISTMODEL2, PARA QUE SE PUEDA AL MOMENTO DE SELECCIONAR LA OPCIN QUE TIENE ESTE BOTN PUEDA CARGAR LOS NOMBRES DEL ARCHIVO EL CUAL FUERON METIDOS EL DE LAS CANCIONES, CON LA LLAMADA DE LA CLASE FIEL LLAMA AL ARCHIVO Y LO MUESTRA EN ESTE BOTN.*/ } private void jList3ValueChanged(javax.swing.event.ListSelectionEvent evt) { // TODO add your handling code here: } // Variables declaration - do not modify private javax.swing.JButton jButton2; private javax.swing.JButton jButton3; private javax.swing.JLabel jLabel1; private javax.swing.JLabel jLabel2; private javax.swing.JLabel jLabel3; private javax.swing.JLabel jLabel4; private javax.swing.JLabel jLabel5; private javax.swing.JList jList1; private javax.swing.JList jList2; private javax.swing.JList jList3; private javax.swing.JScrollPane jScrollPane1; private javax.swing.JScrollPane jScrollPane2; private javax.swing.JScrollPane jScrollPane3; private javax.swing.JPanel mainPanel; private javax.swing.JMenuBar menuBar; private javax.swing.JProgressBar progressBar; private javax.swing.JLabel statusAnimationLabel; private javax.swing.JLabel statusMessageLabel; private javax.swing.JPanel statusPanel; // End of variables declaration private final Timer messageTimer;//Declaracin de una constante. private final Timer busyIconTimer;//Declaracin de una constante. private final Icon idleIcon;//Declaracin de una constante. private final Icon[] busyIcons = new Icon[15];//Declaracin de una constante de tipo arreglo. private int busyIconIndex = 0; File a0 = new File("Biblioteca.dat");//Llamada al archivo Biblioteca, que tiene los nombres de los artistas. File a01 = new File("Canciones.dat");//Llamada al archivo Canciones, que tiene los nombres de las canciones. Reproductor mi_reproductor = new Reproductor();//Declaracin del objeto de la clase Reproductor, el cual contiene todos los mtodos.

Esto es el cdigo de la clase, la cual realizar lo dicho en la introduccin.

private JDialog aboutBox;}

UML DE LA CLASE Proyecto:


Proyecto

+crear(): void +alta(): void

CDIGO DE LA CLASE Proyecto:


package proyectofinal;//Nombre del paquete import java.io.*;//Importacind e la paquetera .io import javax.swing.*;//Importacind e la paquetera javax. public class Proyecto {//Nombre de la clase. private String nombre;//se declara nombre como tipo de dato string con un modificador privado File Original= new File("Biblioteca.dat") ;//se instancia el objeto original del archivo bibliotecas.dat File Origi= new File("Canciones.dat");//se instancia el objeto origi del archivo canciones.dat FileOutputStream or= null;//se crea un filtro para el archivo de escritura DataOutputStream or1= null;//se crea un flujo de bytes para el archivo public void crear() throws IOException{ //se crea un metodo or = new FileOutputStream(Original);//se crea objeto or que filtra bytes y toma valor de origi or1 = new DataOutputStream(or);//se crea objeto or1 que crea un flujo de bytes y toma valor de or } public void alta() throws IOException{ //se crea un metodo or = new FileOutputStream(Original, true);//se crea objeto or que filtra bytes y toma valor de origi or1 = new DataOutputStream(or);//se crea objeto or1 que crea un flujo de bytes y toma valor de or String opcion1="s";//"s" es el valor que tiene la variable de tipo cadena do{JOptionPane.showMessageDialog(null,"Ingresa los Datos Que Se Te Pidan...");//nos despliega un cuadro de dialogo con un mensage nombre= JOptionPane.showInputDialog("Ingresa Nombre de Artista:");//a la variable cancion se le asigna el contenido que le de el usuario al cuadro del dialogo or1.writeUTF(nombre);//escribe en el archivo la cancion con el objeto del metodo opcion1 =JOptionPane.showInputDialog("\tHa Terminado Con El Registro? s\n: ");//nos despliega un cuadro de dialogo donde nos manda un mensagepregunta si deceas terminar el regitro }while(opcion1.equals("n"));}//pregunta si deceas terminar el regitro }

UML DE LA CLASE Cancion:


Cancion

+crear(): void +alta(): void

CDIGO DE LA CLASE Cancion:


package proyectofinal;//Nombre del paquete import java.io.*;//Importacind e la paquetera .io import javax.swing.*;//Importacind e la paquetera javax. public class Canciones {//Nombre de la clase. private String cancion;//se declara cancion como tipo de dato string con un modificador privado File Origi= new File("Canciones.dat");//se instancia el objeto origi del archivo canciones.dat FileOutputStream or= null;//se crea un filtro para el archivo de escritura DataOutputStream or1= null;//se crea un flujo de bytes para el archivo public void crear() throws IOException{//se crea un metodo or = new FileOutputStream(Origi);//se crea objeto or que filtra bytes y toma valor de origi

or1 = new DataOutputStream(or);//se crea objeto or1 que crea un flujo de bytes y toma valor de or } public void altaCancion() throws IOException{//se crea un metodo or = new FileOutputStream(Origi, true);//se crea objeto or que filtra bytes y toma valor de origi or1 = new DataOutputStream(or);//se crea objeto or1 que crea un flujo de bytes y toma valor de or String opcion1="s";//"s" es el valor que tiene la variable de tipo cadena do{JOptionPane.showMessageDialog(null,"Ingresa los Datos Que Se Te Pidan...");//nos despliega un cuadro de dialogo con un mensage cancion= JOptionPane.showInputDialog("Ingresa Nombre de la Cancin:");//a la variable cancion se le asigna el contenido que le de el usuario al cuadro del dialogo or1.writeUTF(cancion);//escribe en el archivo la cancion con el objeto del metodo opcion1 =JOptionPane.showInputDialog("\tHa Terminado Con El Registro? s\n: ");//nos despliega un cuadro de dialogo donde nos manda un mensagepregunta si deceas terminar el regitro }while(opcion1.equals("n"));} //pregunta si deceas terminar el regitro }

UML DE LA CLASE Ejecuta:


Ejecuta

+static main(String [] args): void

CDIGO DE LA CLASE Ejecuta:


package proyectofinal;//Nombre del paquete import java.io.*;//Importacind e la paquetera .io import javax.swing.*;//Importacind e la paquetera javax. public class Ejecuta {//Nombre de la clase. public static void main(String [] args) throws IOException//Mtodo que va a ejecutar esta clase. { JOptionPane.showMessageDialog(null,"Bienvenido");//cuadro de dialogo que nos despliega un mensage Proyecto Metodo = new Proyecto();//se instancia el objeto metodo de la clase proyecto Canciones can = new Canciones();//se instancia el objeto can de la clase canciones for(;;) {int opc=Integer.parseInt(JOptionPane.showInputDialog("Menu\n1.Crear\n2.Altas\n3.Altas Canciones\n4.Salir"));//este es para que nos despliege un pequeo menu en un cuadro de dialogo switch(opc)// {case 1:Metodo.crear();//que en el 1 nos de la opcion de crear archivo break; case 2: Metodo.alta();//que en el 2 nos de la opcion de dar de altas los artistas break; case 3: can.altaCancion();//que en el 3 nos de la opcion de dar de alta las canciones de los artistas break; case 4:System.exit(3);}}}}//salir del cuadro de dialogo

UML DE LA CLASE Reproductor:


Reproductor +Play(): void +AbrirFichero(ru ta: String): void

CDIGO DE LA CLASE Ejecuta:


package proyectofinal;//Nombre del paquete.

import javazoom.jlgui.basicplayer.BasicPlayer;//]Importacion del paquete. import java.io.File;//Importacin de la calse File public class Reproductor {//Nombre de la clase. private BasicPlayer player = new BasicPlayer();//Mtodp para inciar con el sonido. public void Play() throws Exception {//Mtodo para emepezar, player.play();

public void AbrirFichero(String ruta) throws Exception {//Mtodo para abrir el archivo. player.open(new File(ruta)); } }

Es as como quedan los cdigos declarados, y listos para usarse, ahora veamos la corrida que tienes: Al comenzar con la siguiente interface:

Esta es la interfaz, como se puede apreciar an no hay nombres o imgenes, si no que al poner al botn CARGAR ARTISTA, ir al archivo Biblioteca, y lo traer y lo meter en la lista o lo cargara. Al igual es lo mismo para las canciones. En la siguiente interfaz se podr ver que ya se cargan los artistas y sus canciones:

Esto es lo que muestra al accionar los botones, los cuales trae del archivo creado. Ahora la seleccionar un artista:

Como se puede apreciar, al seleccionar un artista se selecciona el gener y la cancin, la cual tambin muestra la imagen y despus reproduce el sonido. Al poner otro artista:

Lo nico que hace es cambiar de artista, as mismo la imagen, y ms parte reproduce la cancin de tal artista.

FIN DE PROYECTO.

CONCLUSIONES:
Como se mencion anteriormente, se trabaj con archivos secuenciales y multimedia, algunos de los temas vistos en el semestre. Lo que se hizo fue tratar de mostrar la imagen del artista, la reproduccin de la cancin y la seleccin del gener y canciones, esto se hizo a base de que al seleccionar al artista, seleccione el gener y despus la cancin, que al momento de hacer esto se muestre la imagen y reproduzca la cancin. Al empezar este proyecto se daba por sencillo, pero al tratar de realizarlos nos llev tiempo en entender y saber lo que hace y para qu sirve. Tambin en lo que se nos dificulto ms fue al tratar de realizar las canciones, porque no sabamos cmo se iba a codificar o como se iba a trabajar. Tambin en parte fue para la imagen que no sabamos cmo hacerlo al no saber dnde guardarlas en la carpeta para que salga en el JLabel. En cierta parte eso fue lo ms difcil, lo dems fue un poco ms sencillo de hacer, espero que al final de buenos frutos este esfuerzo que rendimos, al realizarlo. Le queremos dar las gracias por todo profesor, a pesar de que es la ltima materia de programacin, gracias por su atenta atencin. GRACIAS POR TODO.

Potrebbero piacerti anche