KickJava   Java API By Example, From Geeks To Geeks.

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


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.BorderLayout JavaDoc;
22 import java.awt.event.*;
23
24 import javax.swing.*;
25
26 import org.lucane.applications.audioconf.AudioConf;
27 import org.lucane.client.Client;
28 import org.lucane.client.widgets.ManagedWindow;
29
30 public class Controller
31 implements ActionListener, WindowListener
32 {
33     private AudioConf plugin;
34     private ManagedWindow controller;
35     
36     public Controller(AudioConf plugin)
37     {
38         this.plugin = plugin;
39     }
40     
41     public void showController()
42     {
43         controller = new ManagedWindow(plugin, plugin.getTitle());
44             
45         JButton stop = new JButton(plugin.tr("btn.stop"));
46         stop.addActionListener(this);
47         String JavaDoc msg = plugin.tr("msg.nowStreamingWith");
48         msg = msg.replaceAll("%1", plugin.getFriendName());
49         JLabel label = new JLabel(msg);
50
51         try {
52             label.setIcon(plugin.getImageIcon(plugin.getIcon()));
53             stop.setIcon(Client.getImageIcon("cancel.png"));
54         } catch(Exception JavaDoc e) {
55             //no icons
56
}
57                         
58         controller.getContentPane().setLayout(new BorderLayout JavaDoc());
59         controller.getContentPane().add(label, BorderLayout.CENTER);
60         controller.getContentPane().add(stop, BorderLayout.EAST);
61         
62         controller.addWindowListener(this);
63         controller.show();
64     }
65     
66     public void hideController()
67     {
68         controller.dispose();
69     }
70
71     public void actionPerformed(ActionEvent ae)
72     {
73         plugin.stopAndExit();
74     }
75
76     public void windowIconified(WindowEvent we) {}
77     public void windowDeiconified(WindowEvent we) {}
78     public void windowActivated(WindowEvent we) {}
79     public void windowDeactivated(WindowEvent we) {}
80     public void windowOpened(WindowEvent we) {}
81     public void windowClosing(WindowEvent we) {}
82     public void windowClosed(WindowEvent we)
83     {
84         plugin.stopAndExit();
85     }
86 }
Popular Tags