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();