panel.setBorder(BorderFactory.createEmptyBorder(10, 10, 5, 30));
Box mainBox = Box.createVerticalBox();
JPanel misc = new JPanel(new GridLayout(2, 2, 10, 10));
final AudioOutput output = app.getPlayer().getAudioOutput();
Box mix = Box.createHorizontalBox();
mix.add(new JLabel("Audio Mixer: "));
Vector<String> mixerVector = new Vector<String>();
mixerVector.add("Detect automatically");
final Mixer.Info[] mixerInfo = AudioSystem.getMixerInfo();
int selectedIndex = Arrays.asList(mixerInfo).indexOf(output.getMixer());
for (Mixer.Info info : mixerInfo) {
String s = info.getDescription() + ", " + info.getName();
mixerVector.add(s);
}
final JComboBox mixers = new JComboBox(mixerVector);
mixers.setSelectedIndex(selectedIndex + 1);
mixers.setPrototypeDisplayValue(mixerVector.get(0));
mix.add(mixers);
mainBox.add(mix);
mainBox.add(Box.createVerticalStrut(5));
mainBox.add(misc);
misc.add(new JLabel("Default Encoding for Tags"));
Charset charset = AudioFileReader.getDefaultCharset();
final JComboBox encoding = new JComboBox(Charset.availableCharsets().values().toArray());
encoding.setSelectedItem(charset);
misc.add(encoding);
final JCheckBox oneInstance = new JCheckBox("Allow only one instance (needs restart)");
oneInstance.setSelected(config.getBoolean("system.oneInstance", false));
misc.add(oneInstance);
panel.add(mainBox, BorderLayout.NORTH);
applyButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
int index = mixers.getSelectedIndex();
if (index > 0) {
Mixer.Info info = mixerInfo[index - 1];
output.setMixer(info);
} else {
output.setMixer(null);
}
AudioFileReader.setDefaultCharset((Charset) encoding.getSelectedItem());
config.setBoolean("system.oneInstance", oneInstance.isSelected());
}
});