Skip to main content

Recordset with audio and JTextArea...

No replies
paul78
Offline
Joined: 2012-08-03
Points: 0

hello averybody....

i'm creatibg one program....
in this program i have one db and in table i have nome, basi, testo.

in JList show only "nome"

but in doubleCick on "nome" i want show song and text...song with jmf and text in JTextArea...

in my code when click on song i can listen and to see always the first recordset....

i want open base, testo relative "nome"

thi is cod.

try {	            			 
            conn = DriverManager.getConnection("jdbc:mysql://localhost/basi?user=root&password=root");
            stmt = conn.createStatement();
            //per visualizzare il db
            String sql = "SELECT base, testo FROM "+combo2.getSelectedItem();
            rs = stmt.executeQuery(sql);
           
            String testo = "" ;
            String base = "";

                        if (rs.next())  {
                       
                        removePreviousPlayer();                      
                        testo = rs.getString("testo"); 
                        base = rs.getString("base");
                        file = new File(base);                        
                        MediaLocator mrl = new MediaLocator( file.toURI().toURL() );                            
                            player = Manager.createPlayer(mrl);
                            player.addControllerListener( new EventHandler() );
                            player.start();          
            File f = new File(testo);
            br = new BufferedReader(new FileReader(f));
            textArea.setText(null);
            String st = "";
                    while((st=br.readLine()) != null){
                    if (!st.startsWith(">")) {
                    textArea.append(st + "\n");
                    textArea.setFont(new Font("times new roman", Font.BOLD, 30));                   
                    }
                    }
                        }            
            stmt.close();
            conn.close();
            }
            catch (Exception exc) {
            System.out.println("Errore: "+ exc.getMessage());
            }

i hope you can understand my english.....