1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package org.xnap.gui.action;
21
22 import java.awt.event.ActionEvent;
23
24 import javax.swing.AbstractAction;
25 import javax.swing.Action;
26 import javax.swing.JOptionPane;
27
28 import org.xnap.XNap;
29 import org.xnap.chat.ChatProvider;
30 import org.xnap.gui.util.IconHelper;
31
32 /***
33 * Provides an action that prompts the user for a channel name and
34 * then joins a channel on a {@link ChatProvider} object by calling
35 * {@link ChatProvider#join(String)}.
36 */
37 public class JoinChannelAction extends AbstractAction
38 {
39
40
41
42
43
44 private ChatProvider cp;
45
46
47
48 public JoinChannelAction(ChatProvider cp)
49 {
50 this.cp = cp;
51
52 putValue(Action.NAME, XNap.tr("Create/Join Channel") + "...");
53 putValue(Action.SHORT_DESCRIPTION,
54 XNap.tr("Prompts for a channel name."));
55 putValue(IconHelper.XNAP_ICON, "filenew.png");
56 }
57
58
59
60 public void actionPerformed(ActionEvent event)
61 {
62 String name = JOptionPane.showInputDialog
63 (null, XNap.tr("Name"),
64 XNap.tr("Join Channel"), JOptionPane.QUESTION_MESSAGE);
65
66 if (name != null && name.trim().length() > 0) {
67 cp.join(name.trim());
68 }
69 }
70
71 }