KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > lucane > applications > audioconf > gui > AudioConfigPanel


1 /*
2  * Lucane - a collaborative platform
3  * Copyright (C) 2004 Vincent Fiack <vfiack@mail15.com>
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18  */

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 JavaDoc[] 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 JavaDoc tr(String JavaDoc s)
81     {
82         return plugin.tr(s);
83     }
84 }
Popular Tags