Ads 468x60px

Rabu, 16 November 2011

penambahan coding pada project file mp3 dan file text

Tulis method ini sebelum coding pada atribut/komponen:

public void init() {
        try {
            java.awt.EventQueue.invokeAndWait(new Runnable() {

                public void run() {
                    initComponents();
                }
            });
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }
    void mainkan(){
        String main=jList1.getSelectedValue().toString();
        try{
            playerSS = Manager.createPlayer(new URL("file",null,main));
            playerSS.start();
           
        }catch(Exception ex){}
    }
    void munculkan(){
        String s;
        String tulis=jList2.getSelectedValue().toString();
        try {
             URL source = new URL("file",null,tulis);
                    BufferedReader br = new BufferedReader(new InputStreamReader(source.openStream()));
                    s = br.readLine();
                    jTextArea2.setText(s);
                    while(null != (s=br.readLine())){
                    jTextArea2.setText(jTextArea2.getText()+"\n"+s);
                    }           
        }catch(Exception ex){}
    }
    void delete(){
    JFileChooser fc=new JFileChooser();
        JFrame jf=new JFrame();
        int ret = fc.showOpenDialog(jf.add(fc));
        int hapus = jList1.getModel().getSize();
        if(ret==JFileChooser.APPROVE_OPTION) {
            File file = fc.getSelectedFile();
            baru= file.getPath().toString();
            String[] txt = new String[]{baru};  
            model.add(hapus, baru);
}      
        jList1.setModel(model);
    }

0 komentar:

Posting Komentar

clock