FileDocCategorySizeDatePackage
DataLineControlGUI.javaAPI DocExample1988Mon Jan 09 11:02:00 GMT 2006None

DataLineControlGUI

public class DataLineControlGUI extends JPanel

Fields Summary
PCMFilePlayer
player
JButton
startButton
Constructors Summary
public DataLineControlGUI(File f)

        super();
        try {
            player = new PCMFilePlayer (f);
        } catch (Exception ioe) {
            add (new JLabel ("Error: " +
                             ioe.getMessage()));
            return;
        }
        DataLine line = player.getLine();
        // layout
        // line 0: name
        setLayout (new GridBagLayout());
        GridBagConstraints gbc = new GridBagConstraints();
        gbc.gridy = 0;
        gbc.fill = GridBagConstraints.HORIZONTAL;
        gbc.gridwidth = 2;
        gbc.anchor = GridBagConstraints.SOUTH;
        add (new JLabel ("File:  " + 
                         player.getFile().getName()), gbc);
        // subsequent lines: controls
        gbc.gridwidth = 1;
        Control[] controls = line.getControls();
        for (int i=0; i<controls.length; i++) {
            gbc.gridx = 0;
            gbc.gridy++;
            gbc.anchor = GridBagConstraints.EAST;
            add (new JLabel(controls[i].getType().toString()), gbc);
            JComponent controlComp =
                ControlComponentFactory.getComponentFor (controls[i]);
            gbc.gridx = 1;
            gbc.anchor = GridBagConstraints.WEST;
            add (controlComp, gbc);
        }

        // 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();
        DataLineControlGUI demo = 
            new DataLineControlGUI (file);
        
        JFrame f = new JFrame ("JavaSound control");
        f.getContentPane().add (demo);
        f.pack();
        f.setVisible(true);