private JComboBox getMixerComboBox() { if (mixerComboBox == null) { Mixer.Info[] mixerInfo = AudioSystem.getMixerInfo(); Line.Info clipLineInfo = new Line.Info(Clip.class); Vector<Mixer.Info> mixers = new Vector<Mixer.Info>(); for (Mixer.Info mi : mixerInfo) { if (AudioSystem.getMixer(mi).getSourceLineInfo(clipLineInfo).length > 0) { mixers.add(mi); } } mixerComboBox = new JComboBox(mixers); mixerComboBox.setRenderer(new MixerInfoCellRenderer()); mixerComboBox.addActionListener(eventHandler); } return mixerComboBox; }
private void mixerComboBoxActionPerformed() { Mixer mixer = AudioSystem.getMixer((Mixer.Info) mixerComboBox.getSelectedItem()); Line.Info lineInfo = mixer.getSourceLineInfo(new Line.Info(Clip.class))[0]; boolean volumeSupported; boolean panSupported; try { Line line = mixer.getLine(lineInfo); volumeSupported = line.isControlSupported(FloatControl.Type.MASTER_GAIN); panSupported = line.isControlSupported(FloatControl.Type.PAN); } catch (LineUnavailableException e) { volumeSupported = false; panSupported = false; } enableMixerVolumeCheckBox.setEnabled(volumeSupported); enableMixerPanCheckBox.setEnabled(panSupported); }