KickJava   Java API By Example, From Geeks To Geeks.

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


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 javax.swing.*;
22 import java.awt.*;
23 import java.awt.event.*;
24
25 import org.lucane.applications.audioconf.AcceptationThread;
26 import org.lucane.applications.audioconf.AudioConf;
27 import org.lucane.client.Client;
28
29 public class ConfigDialog extends JDialog
30 implements ActionListener
31 {
32     private AudioConf plugin;
33     
34     private AudioConfigPanel config;
35     private JButton btnOk;
36     private JButton btnCancel;
37     
38     public ConfigDialog(AudioConf plugin)
39     {
40         this.setTitle(plugin.getTitle());
41     
42         this.plugin = plugin;
43         this.config = new AudioConfigPanel(plugin);
44         
45         this.getContentPane().setLayout(new BorderLayout());
46         this.getContentPane().add(this.config, BorderLayout.CENTER);
47         this.initButtons();
48         this.pack();
49     }
50     
51     private void initButtons()
52     {
53         this.btnOk = new JButton(tr("btn.ok"), Client.getImageIcon("ok.png"));
54         this.btnCancel = new JButton(tr("btn.cancel"), Client.getImageIcon("cancel.png"));
55         
56         btnOk.addActionListener(this);
57         btnCancel.addActionListener(this);
58         
59         JPanel buttons = new JPanel(new GridLayout(1, 2));
60         buttons.add(btnOk);
61         buttons.add(btnCancel);
62         
63         JPanel container = new JPanel(new BorderLayout());
64         container.add(buttons, BorderLayout.EAST);
65         
66         this.getContentPane().add(container, BorderLayout.SOUTH);
67     }
68     
69     public void actionPerformed(ActionEvent e)
70     {
71         if(e.getSource().equals(btnOk))
72             new AcceptationThread(plugin, this.config.getAudioConfig()).start();
73         else if(e.getSource().equals(btnCancel))
74             plugin.exit();
75
76         this.dispose();
77     }
78     
79     private String JavaDoc tr(String JavaDoc s)
80     {
81         return plugin.tr(s);
82     }
83 }
Popular Tags