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

Quick Search    Search Deep

Source code: org/mitre/cvw/CVWAnnouncementDialog.java


1   /*
2    * Copyright (c) 1996-2000. The MITRE Corporation (http://www.mitre.org/).
3    * All rights reserved.
4    * CVW comes with ABSOLUTELY NO WARRANTY. See license for details.
5    */
6   
7   package org.mitre.cvw;
8   
9   import javax.swing.*;
10  import java.awt.*;
11  import java.awt.event.*;
12  
13  /**
14   * Creates a general announcement dialog that can be displayed to all the users
15   *
16   * @version 1.0
17   * @author unascribed
18   */
19  public class CVWAnnouncementDialog extends CVWDialog {
20  
21    protected GridBagLayout gbl = new GridBagLayout();
22    JTextArea announcementText;
23    JButton dismissBtn;
24    JCheckBox displayCkBox;
25  
26    /**
27     * Constructor
28     *
29     * @param appletFrame Parent window to display the dialog in.
30     * @param msg Message to display in the dialog.
31     */
32    CVWAnnouncementDialog(Frame appletFrame, String msg) {
33      super(appletFrame, false);
34      init(msg);
35    }
36  
37    /**
38     * Initializes the dialog
39     *
40     * @param msg The message to display in the dialog
41     */
42    public void init(String msg) {
43      this.setTitle("CVW - Announcement");
44      
45      Rectangle rect = CVWCoordinator.getInstance().getBounds();
46      setLocation(rect.x + (int)(rect.width/3), rect.y + (int)(rect.height/3));
47      
48      setContentsLayout(gbl);
49      
50      announcementText = new JTextArea(msg, 5, 50);
51      announcementText.setFont(new Font("sansserif", Font.PLAIN, 12));
52      VertScrollPane scroll = new VertScrollPane(announcementText, true);
53      displayCkBox = new JCheckBox("Do not display this announcement again");
54  
55      dismissBtn = new JButton("Close");
56      dismissBtn.addActionListener(new ActionListener() {
57        public void actionPerformed(ActionEvent e) {
58    cancel();
59        }
60      });
61  
62      constrain(this, scroll, gbl, 0, 0, 1, 1, GridBagConstraints.BOTH,
63                GridBagConstraints.NORTH, 1.0, 1.0, 10, 5, 10, 5, 0, 0); 
64  
65      constrain(this, displayCkBox, gbl, 0, 1, 1, 1, GridBagConstraints.NONE,
66                GridBagConstraints.WEST, 0.0, 0.0, 10, 5, 10, 5, 0, 0); 
67  
68      constrain(this, dismissBtn, gbl, 0, 2, 1, 1, GridBagConstraints.NONE,
69                GridBagConstraints.CENTER, 0.0, 0.0, 10, 5, 10, 5, 0, 0); 
70      
71  
72      announcementText.setEditable(false);
73      setBackground(Color.lightGray);
74  
75      // srj 3/1/99 1.1 events
76      this.addWindowListener(new WindowAdapter() {
77        public void windowClosing(WindowEvent e) {
78    cancel();
79        }
80      });
81  
82      //center();
83      pack();
84      setVisible(true);
85    }
86  
87  /**
88   * Removes the dialog instance and tells the CVW server to no longer show the system
89   * message if the user checked the checkbox.
90   */
91    public void cancel() {
92      if (displayCkBox.isSelected()) 
93        CVWServerComm.sendMCPCmdToServer("#$#cvw-system-motd-off");
94      super.cancel();
95    }
96  
97  }
98