KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > calipso > reportgenerator > userinterface > LicenceFrame


1 package com.calipso.reportgenerator.userinterface;
2
3 import com.calipso.reportgenerator.common.LanguageTraslator;
4 import com.calipso.reportgenerator.client.ReportManagerService;
5
6 import javax.swing.*;
7 import java.awt.event.ActionListener JavaDoc;
8 import java.awt.event.ActionEvent JavaDoc;
9 import java.awt.*;
10 import java.io.File JavaDoc;
11
12 /**
13  * Calipso Software
14  * User: Breto
15  * Date: 18/04/2006
16  * Time: 17:56:15
17  */

18 public class LicenceFrame extends JDialog implements ActionListener JavaDoc {
19   private JButton btAccept;
20   private JButton btCancel;
21   private boolean hasCanceled;
22   private JTextField tfName;
23
24
25   public LicenceFrame(Frame owner, String JavaDoc title, boolean modal) throws HeadlessException {
26     super(owner, title, modal);
27     Image icon = ReportManagerService.getConfiguration().getImage("icon");
28     if(icon != null && owner!=null) {
29       owner.setIconImage(icon);
30     }
31     hasCanceled = false;
32     createComponents();
33   }
34
35
36   public static boolean accept(){
37     LicenceFrame licenceFrame = new LicenceFrame(new JFrame(), LanguageTraslator.traslate("582"), true);
38     if(!licenceFrame.getHasCanceled()) {
39       return true;
40     }
41     return false;
42
43   }
44
45   private boolean getHasCanceled() {
46     return hasCanceled;
47   }
48
49   protected void createComponents() {
50     getContentPane().setLayout(new BorderLayout());
51     getContentPane().add(createNorthPanel(), BorderLayout.CENTER);
52     getContentPane().add(createSouthPanel(), BorderLayout.SOUTH);
53     java.awt.Dimension JavaDoc screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
54     setLocation(100, 100 );
55     setSize(new Dimension(620, 550));
56     setVisible(true);
57   }
58
59   /**
60    * Crea el panel del sur
61    * @return
62    */

63   protected JComponent createSouthPanel() {
64     FlowLayout layout = new FlowLayout(FlowLayout.RIGHT);
65     JPanel pnlSouth = new JPanel(layout);
66     btAccept = new JButton(LanguageTraslator.traslate("112"));
67     btAccept.addActionListener(this);
68     btCancel = new JButton(LanguageTraslator.traslate("113"));
69     btCancel.addActionListener(this);
70     pnlSouth.add(btAccept);
71     pnlSouth.add(btCancel);
72     return pnlSouth;
73   }
74
75   /**
76    * Crea el panel del norte
77    * @return
78    */

79   protected JComponent createNorthPanel() {
80     JPanel pnlNorth = new JPanel(new GridLayout(1, 1));
81     JTextArea jTextArea = new JTextArea();
82     jTextArea.setEditable(false);
83     jTextArea.append(getBSDText());
84     pnlNorth.add(jTextArea);
85     return pnlNorth;
86   }
87
88   private String JavaDoc getBSDText() {
89     return new String JavaDoc("BSD License\n" +
90             "============\n" +
91             "\n" +
92             "Redistribution and use in source and binary forms, with or without modification, \n" +
93             "are permitted provided that the following conditions are met:\n" +
94             " 1. Redistributions of source code must retain the above copyright notice, \n" +
95             " this list of conditions and the following disclaimer. \n" +
96             " 2. Redistributions in binary form must reproduce the above copyright notice, \n" +
97             " this list of conditions and the following disclaimer in the documentation \n" +
98             " and/or other materials provided with the distribution. \n" +
99             " 3. All advertising materials mentioning features or use of this software must \n" +
100             " display the following acknowledgement:\n" +
101             " This product includes software developed by the NetBSD Foundation, Inc. \n" +
102             " and its contributors. \n" +
103             " \n" +
104             " 4. Neither the name of Calipso nor the names of its contributors \n" +
105             " may be used to endorse or promote products derived from this software without \n" +
106             " specific prior written permission. \n" +
107             "\n" +
108             "THIS SOFTWARE IS PROVIDED THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' \n" +
109             "AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED \n" +
110             "WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. \n" +
111             "IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, \n" +
112             "INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, \n" +
113             "PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS \n" +
114             "INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, \n" +
115             "STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT\n" +
116             "OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n" +
117             "");
118   }
119
120   public void actionPerformed(ActionEvent JavaDoc e) {
121     if(e.getSource() == btAccept) {
122       dispose();
123     } else {
124       hasCanceled = true;
125       dispose();
126     }
127   }
128
129 }
130
Popular Tags