3 The class is used to show a License Agreement page in
6 Copyright (c) 2006, Intel Corporation
7 All rights reserved. This program and the accompanying materials
8 are licensed and made available under the terms and conditions of the BSD License
9 which accompanies this distribution. The full text of the license may be found at
10 http://opensource.org/licenses/bsd-license.php
12 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
13 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
17 package org
.tianocore
.packaging
.workspace
.ui
;
19 import java
.awt
.event
.ActionEvent
;
20 import java
.awt
.event
.ActionListener
;
21 import java
.awt
.event
.WindowEvent
;
23 import javax
.swing
.JButton
;
24 import javax
.swing
.JLabel
;
25 import javax
.swing
.JPanel
;
26 import javax
.swing
.JRadioButton
;
27 import javax
.swing
.JScrollPane
;
28 import javax
.swing
.JTextArea
;
30 import org
.tianocore
.packaging
.common
.ui
.IFrame
;
33 The class is used to show a License Agreement page in
36 @since CreateMdkPkg 1.0
39 public class LicenseAgreement
extends IFrame
implements ActionListener
{
42 /// Define class Serial Version UID
44 private static final long serialVersionUID
= 5507683268692334188L;
47 // Define class members
49 private JPanel jContentPane
= null;
51 private JTextArea jTextArea
= null;
53 private JTextArea jTextArea1
= null;
55 private JPanel jPanel
= null;
57 private JButton jButtonBack
= null;
59 private JButton jButtonNext
= null;
61 private JButton jButtonCancel
= null;
63 private JLabel jLabel
= null;
65 private JRadioButton jRadioButtonAgree
= null;
67 private JRadioButton jRadioButtonDisagree
= null;
69 private JScrollPane jScrollPane
= null;
71 private JTextArea jTextArea2
= null;
73 private JLabel jLabel1
= null;
75 private Welcome w
= null;
77 private SelectDestinationDirectory sdd
= null;
80 This method initializes jTextArea
82 @return javax.swing.JTextArea jTextArea
85 private JTextArea
getJTextArea() {
86 if (jTextArea
== null) {
87 jTextArea
= new JTextArea();
88 jTextArea
.setLocation(new java
.awt
.Point(0, 0));
89 jTextArea
.setText(" License Agreement");
90 jTextArea
.setFont(new java
.awt
.Font("Dialog", java
.awt
.Font
.BOLD
, 14));
91 jTextArea
.setEditable(false);
92 jTextArea
.setSize(new java
.awt
.Dimension(495, 20));
98 This method initializes jTextArea1
100 @return javax.swing.JTextArea jTextArea1
103 private JTextArea
getJTextArea1() {
104 if (jTextArea1
== null) {
105 jTextArea1
= new JTextArea();
106 jTextArea1
.setLocation(new java
.awt
.Point(0, 20));
107 jTextArea1
.setText(" Please read the following important information before continuing.");
108 jTextArea1
.setEditable(false);
109 jTextArea1
.setSize(new java
.awt
.Dimension(495, 35));
115 This method initializes jPanel
117 @return javax.swing.JPanel jPanel
120 private JPanel
getJPanel() {
121 if (jPanel
== null) {
122 jLabel1
= new JLabel();
123 jLabel1
.setText(" this agreement before continuing with the installation.");
124 jLabel1
.setLocation(new java
.awt
.Point(30, 35));
125 jLabel1
.setSize(new java
.awt
.Dimension(435, 20));
126 jLabel
= new JLabel();
127 jLabel
.setText("Please read the following License Agreement. You must accept the terms of");
128 jLabel
.setLocation(new java
.awt
.Point(30, 15));
129 jLabel
.setSize(new java
.awt
.Dimension(435, 20));
130 jPanel
= new JPanel();
131 jPanel
.setLayout(null);
132 jPanel
.setBorder(javax
.swing
.BorderFactory
.createBevelBorder(javax
.swing
.border
.BevelBorder
.LOWERED
));
133 jPanel
.setSize(new java
.awt
.Dimension(494, 251));
134 jPanel
.setLocation(new java
.awt
.Point(0, 55));
135 jPanel
.add(jLabel
, null);
136 jPanel
.add(getJRadioButtonAgree(), null);
137 jPanel
.add(getJRadioButtonDisagree(), null);
138 jPanel
.add(getJScrollPane(), null);
139 jPanel
.add(jLabel1
, null);
145 This method initializes jButtonBack
147 @return javax.swing.JButton jButtonBack
150 private JButton
getJButtonBack() {
151 if (jButtonBack
== null) {
152 jButtonBack
= new JButton();
153 jButtonBack
.setText("Back");
154 jButtonBack
.setSize(new java
.awt
.Dimension(90, 20));
155 jButtonBack
.setLocation(new java
.awt
.Point(200, 315));
156 jButtonBack
.setMnemonic('B');
157 jButtonBack
.addActionListener(this);
163 This method initializes jButtonNext
165 @return javax.swing.JButton jButtonNext
168 private JButton
getJButtonNext() {
169 if (jButtonNext
== null) {
170 jButtonNext
= new JButton();
171 jButtonNext
.setText("Next");
172 jButtonNext
.setBounds(new java
.awt
.Rectangle(292, 315, 90, 20));
173 jButtonNext
.setEnabled(false);
174 jButtonNext
.setMnemonic('N');
175 jButtonNext
.addActionListener(this);
181 This method initializes jButtonCancel
183 @return javax.swing.JButton jButtonCancel
186 private JButton
getJButtonCancel() {
187 if (jButtonCancel
== null) {
188 jButtonCancel
= new JButton();
189 jButtonCancel
.setText("Cancel");
190 jButtonCancel
.setBounds(new java
.awt
.Rectangle(390, 315, 90, 20));
191 jButtonCancel
.setMnemonic('C');
192 jButtonCancel
.addActionListener(this);
194 return jButtonCancel
;
198 This method initializes jRadioButtonAgree
200 @return javax.swing.JRadioButton jRadioButtonAgree
203 private JRadioButton
getJRadioButtonAgree() {
204 if (jRadioButtonAgree
== null) {
205 jRadioButtonAgree
= new JRadioButton();
206 jRadioButtonAgree
.setText("I accept the agreement");
207 jRadioButtonAgree
.setLocation(new java
.awt
.Point(30, 200));
208 jRadioButtonAgree
.setSize(new java
.awt
.Dimension(156, 19));
209 jRadioButtonAgree
.addActionListener(this);
211 return jRadioButtonAgree
;
215 This method initializes jRadioButtonDisagree
217 @return javax.swing.JRadioButton jRadioButtonDisagree
220 private JRadioButton
getJRadioButtonDisagree() {
221 if (jRadioButtonDisagree
== null) {
222 jRadioButtonDisagree
= new JRadioButton();
223 jRadioButtonDisagree
.setText("I do not accept the agreement");
224 jRadioButtonDisagree
.setLocation(new java
.awt
.Point(30, 220));
225 jRadioButtonDisagree
.setSize(new java
.awt
.Dimension(248, 19));
226 jRadioButtonDisagree
.addActionListener(this);
228 return jRadioButtonDisagree
;
232 This method initializes jScrollPane
234 @return javax.swing.JScrollPane jScrollPane
237 private JScrollPane
getJScrollPane() {
238 if (jScrollPane
== null) {
239 jScrollPane
= new JScrollPane();
240 jScrollPane
.setSize(new java
.awt
.Dimension(435, 140));
241 jScrollPane
.setVerticalScrollBarPolicy(javax
.swing
.JScrollPane
.VERTICAL_SCROLLBAR_ALWAYS
);
242 jScrollPane
.setHorizontalScrollBarPolicy(javax
.swing
.JScrollPane
.HORIZONTAL_SCROLLBAR_NEVER
);
243 jScrollPane
.setBorder(javax
.swing
.BorderFactory
.createBevelBorder(javax
.swing
.border
.BevelBorder
.LOWERED
));
244 jScrollPane
.setViewportView(getJTextArea2());
245 jScrollPane
.setLocation(new java
.awt
.Point(30, 55));
251 This method initializes jTextArea2
253 @return javax.swing.JTextArea jTextArea2
256 private JTextArea
getJTextArea2() {
257 if (jTextArea2
== null) {
258 jTextArea2
= new JTextArea();
259 jTextArea2
.setEditable(false);
260 jTextArea2
.setWrapStyleWord(false);
261 jTextArea2
.setLineWrap(true);
262 jTextArea2
.setText("Copyright (c) 2006, Intel Corp.\n"
263 + "All rights reserved. This program and the accompanying materials "
264 + "are licensed and made available under the terms and conditions of the BSD License "
265 + "which may be found at http://opensource.org/licenses/bsd-license.php\n\n\n"
266 + "THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN \"AS IS\" BASIS, "
267 + "WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.");
273 Main class, used for test
278 public static void main(String
[] args
) {
279 LicenseAgreement la
= new LicenseAgreement();
284 This is the default constructor
287 public LicenseAgreement() {
293 This is the override constructor
295 @param welcome The input data of Welcome
298 public LicenseAgreement(Welcome welcome
) {
305 This method initializes this
308 private void init() {
309 this.setSize(500, 390);
310 this.setContentPane(getJContentPane());
311 this.setTitle("Setup - License Agreement");
313 this.getRootPane().setDefaultButton(jButtonNext
);
317 This method initializes jContentPane
319 @return javax.swing.JPanel jContentPane
322 private JPanel
getJContentPane() {
323 if (jContentPane
== null) {
324 jContentPane
= new JPanel();
325 jContentPane
.setLayout(null);
326 jContentPane
.setBorder(javax
.swing
.BorderFactory
.createBevelBorder(javax
.swing
.border
.BevelBorder
.RAISED
));
327 jContentPane
.add(getJTextArea(), null);
328 jContentPane
.add(getJTextArea1(), null);
329 jContentPane
.add(getJPanel(), null);
330 jContentPane
.add(getJButtonBack(), null);
331 jContentPane
.add(getJButtonNext(), null);
332 jContentPane
.add(getJButtonCancel(), null);
338 * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
340 * Override actionPerformed to listen all actions
343 public void actionPerformed(ActionEvent arg0
) {
344 Object obj
= arg0
.getSource();
346 // Disable button next when select jRadioButtonDisagree
348 if (obj
== jRadioButtonDisagree
) {
349 if (jRadioButtonDisagree
.isSelected()) {
350 jRadioButtonAgree
.setSelected(false);
351 jButtonNext
.setEnabled(false);
352 jButtonNext
.setFocusable(false);
354 if (!jRadioButtonAgree
.isSelected() && !jRadioButtonDisagree
.isSelected()) {
355 jRadioButtonDisagree
.setSelected(true);
360 // Enable button next when select jRadioButtonAgree
362 if (obj
== jRadioButtonAgree
) {
363 if (jRadioButtonAgree
.isSelected()) {
364 jRadioButtonDisagree
.setSelected(false);
365 jButtonNext
.setEnabled(true);
366 jButtonNext
.setFocusable(true);
368 if (!jRadioButtonAgree
.isSelected() && !jRadioButtonDisagree
.isSelected()) {
369 jRadioButtonAgree
.setSelected(true);
373 if (obj
== jButtonBack
) {
374 this.setVisible(false);
379 // Show next page when click button Next
381 if (obj
== jButtonNext
) {
383 sdd
= new SelectDestinationDirectory(this);
385 this.setVisible(false);
386 sdd
.setVisible(true);
389 if (obj
== jButtonCancel
) {
395 * @see java.awt.event.WindowListener#windowClosing(java.awt.event.WindowEvent)
397 * Override windowClosing to show confirm quit dialog
400 public void windowClosing(WindowEvent arg0
) {