1 19 package org.lucane.applications.audioconf.gui; 20 21 import java.awt.*; 22 import javax.swing.*; 23 24 import org.lucane.applications.audioconf.*; 25 import org.lucane.applications.audioconf.audio.AudioConfig; 26 27 public class AudioConfigPanel extends JPanel 28 { 29 private AudioConf plugin; 30 31 private JComboBox mode; 32 private JSlider quality; 33 34 public AudioConfigPanel(AudioConf plugin) 35 { 36 super(new GridBagLayout()); 37 38 this.plugin = plugin; 39 40 this.initWidgets(); 41 this.initLayout(); 42 this.setBorder(BorderFactory.createTitledBorder(tr("audio.config"))); 43 } 44 45 private void initWidgets() 46 { 47 Object [] modes = {tr("mode.narrowband"), tr("mode.wideband"), tr("mode.ultrawideband")}; 48 this.mode = new JComboBox(modes); 49 this.quality = new JSlider(0, 10, 3); 50 this.quality.setMajorTickSpacing(10); 51 this.quality.setMinorTickSpacing(1); 52 this.quality.setPaintTicks(true); 53 this.quality.setPaintLabels(true); 54 this.quality.setSnapToTicks(true); 55 } 56 57 private void initLayout() 58 { 59 GridBagConstraints gbc = new GridBagConstraints(); 60 gbc.weightx = 0.3; 61 gbc.gridy = 0; 62 this.add(new JLabel(tr("label.mode")), gbc); 63 gbc.gridy = 1; 64 this.add(new JLabel(tr("label.quality")), gbc); 65 66 gbc.fill = GridBagConstraints.HORIZONTAL; 67 gbc.weightx = 0.7; 68 gbc.gridx = 1; 69 gbc.gridy = 0; 70 this.add(mode, gbc); 71 gbc.gridy = 1; 72 this.add(quality, gbc); 73 } 74 75 public AudioConfig getAudioConfig() 76 { 77 return new AudioConfig(this.mode.getSelectedIndex()+1, this.quality.getValue()); 78 } 79 80 private String tr(String s) 81 { 82 return plugin.tr(s); 83 } 84 } | Popular Tags |