FileDocCategorySizeDatePackage
DataLineInfoGUI2.javaAPI DocExample3193Mon Jan 09 11:02:00 GMT 2006None

DataLineInfoGUI2

public class DataLineInfoGUI2 extends JPanel

Fields Summary
PCMFilePlayerLeveler
player
JButton
startButton
Constructors Summary
public DataLineInfoGUI2(File f)

        super();
        try {
            player = new PCMFilePlayerLeveler (f);
        } catch (Exception ioe) {
            add (new JLabel ("Error: " +
                             ioe.getMessage()));
            return;
        }
        DataLine line = player.getLine();
        // layout
        // line 1: name
        setLayout (new BoxLayout (this, BoxLayout.Y_AXIS));
        add (new JLabel ("File:  " + 
                         player.getFile().getName()));
        // line 2: levels
        add (new DataLineLevelMeter (line));
        // line 3: format info as textarea
        AudioFormat format = line.getFormat();
        JTextArea ta = new JTextArea();
        ta.setBorder (new TitledBorder ("Format"));
        ta.append ("Encoding: " + 
                   format.getEncoding().toString() + "\n");
        ta.append ("Bits/sample: " +
                   format.getSampleSizeInBits() + "\n");
        ta.append ("Channels: " +
                   format.getChannels() + "\n");
        ta.append ("Endianness: " + 
                   (format.isBigEndian() ? " big " : "little") + "\n");
        ta.append ("Frame size: " + 
                   format.getFrameSize() + "\n");
        ta.append ("Frame rate: " +
                   format.getFrameRate() + "\n");
        add (ta);

        // now start playing
        player.start();

    
Methods Summary
public static voidmain(java.lang.String[] args)

        JFileChooser chooser = new JFileChooser();
        chooser.showOpenDialog(null);
        File file = chooser.getSelectedFile();
        DataLineInfoGUI2 demo = 
            new DataLineInfoGUI2 (file);
        
        JFrame f = new JFrame ("JavaSound info");
        f.getContentPane().add (demo);
        f.pack();
        f.setVisible(true);