Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: org/dma/ihm/gui/control/FrameControl.java


1   package org.dma.ihm.gui.control;
2   
3   import java.awt.*;
4   import java.awt.event.*;
5   import java.util.*;
6   
7   import javax.swing.*;
8   
9   import org.dma.ihm.controller.*;
10  import org.dma.ihm.controller.data.*;
11  import org.dma.ihm.game.*;
12  import org.dma.ihm.game.calendar.*;
13  import org.dma.ihm.game.calendar.events.*;
14  import org.dma.ihm.game.match.*;
15  import org.dma.ihm.game.team.*;
16  import org.dma.ihm.gui.*;
17  import org.dma.ihm.gui.lib.*;
18  
19  /**
20   *  The FrameControl contains: - A "MoveOn" Button that fires an actionEvent to
21   *  all listeners ;-) - A label to show some extra text information.
22   *
23   * @author     Bernhard von Gunten
24   * @created    December 29, 2001
25   */
26  public class FrameControl extends JIhmInternalFrame {
27  
28    // Gui controls
29    JButton cmdNext = new JButton();
30    BorderLayout borderLayout1 = new BorderLayout();
31    JLabel lblMsg = new JLabel();
32    JLabel lblDescription = new JLabel();
33    JPanel jPanel1 = new JPanel();
34    BorderLayout borderLayout2 = new BorderLayout();
35    JLabel lblDescription1 = new JLabel();
36    private transient Vector actionListeners;
37  
38  
39    /**
40     *  Conscructs the frame, sets the user (=null)
41     *
42     * @param  user  User to show this frame for
43     */
44    public FrameControl(User user) {
45      super(user);
46      try {
47        jbInit();
48      } catch (Exception e) {
49        e.printStackTrace();
50      }
51    }
52  
53  
54    /**
55     *  JBuilder stuff
56     *
57     * @exception  Exception  Exception
58     */
59    private void jbInit() throws Exception {
60  
61      this.setSize(500, 140);
62      cmdNext.setText(Controller.getTranslation("general.moveOn"));
63      cmdNext.addActionListener(
64        new java.awt.event.ActionListener() {
65          public void actionPerformed(ActionEvent e) {
66            cmdNext_actionPerformed(e);
67          }
68        });
69      this.getContentPane().setLayout(borderLayout1);
70      lblMsg.setText("noMsg");
71      this.setResizable(true);
72      this.setTitle(Controller.getTranslation("frameControl.title"));
73      lblDescription.setText("...");
74      jPanel1.setLayout(borderLayout2);
75      lblDescription1.setText("..");
76      this.getContentPane().add(cmdNext, BorderLayout.CENTER);
77      this.getContentPane().add(jPanel1, BorderLayout.NORTH);
78      jPanel1.add(lblMsg, BorderLayout.NORTH);
79      jPanel1.add(lblDescription, BorderLayout.CENTER);
80      jPanel1.add(lblDescription1, BorderLayout.SOUTH);
81    }
82  
83  
84    /**
85     *  Display a text message on the frame
86     *
87     * @param  title         Title of this frame
88     * @param  username      Username shown in this frame
89     * @param  description   Description line 0
90     * @param  description1  Description line 1
91     */
92    public void setOnlineMessage(String title, String username, String description, String description1) {
93      this.setTitle(title);
94      this.lblMsg.setText(username);
95      this.lblDescription.setText(description);
96      this.lblDescription1.setText(description1);
97      this.repaint();
98    }
99  
100 
101   /**
102    *  Fires an action event out to all listeners
103    *
104    * @param  e  Source event
105    */
106   void cmdNext_actionPerformed(ActionEvent e) {
107     this.fireActionPerformed(e);
108     this.doDefaultCloseAction();
109   }
110 
111 
112   // Event handling
113 
114   /**
115    *  Description of the Method
116    *
117    * @param  l  Description of the Parameter
118    */
119   public synchronized void removeActionListener(ActionListener l) {
120     if (actionListeners != null && actionListeners.contains(l)) {
121       Vector v = (Vector) actionListeners.clone();
122       v.removeElement(l);
123       actionListeners = v;
124     }
125   }
126 
127 
128   /**
129    *  Adds a feature to the ActionListener attribute of the FrameControl object
130    *
131    * @param  l  The feature to be added to the ActionListener attribute
132    */
133   public synchronized void addActionListener(ActionListener l) {
134     Vector v = actionListeners == null ? new Vector(2) : (Vector) actionListeners.clone();
135     if (!v.contains(l)) {
136       v.addElement(l);
137       actionListeners = v;
138     }
139   }
140 
141 
142   /**
143    *  Description of the Method
144    *
145    * @param  e  Description of the Parameter
146    */
147   protected void fireActionPerformed(ActionEvent e) {
148     if (actionListeners != null) {
149       Vector listeners = actionListeners;
150       int count = listeners.size();
151       for (int i = 0; i < count; i++) {
152         ((ActionListener) listeners.elementAt(i)).actionPerformed(e);
153       }
154     }
155   }
156 
157 }