2 Java class GenLongTextDialog.
4 Copyright (c) 2006, Intel Corporation
5 All rights reserved. This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
13 package org
.tianocore
.frameworkwizard
.platform
.ui
;
15 import java
.awt
.BorderLayout
;
16 import java
.awt
.Dimension
;
17 import java
.awt
.Toolkit
;
19 import javax
.swing
.JPanel
;
20 import javax
.swing
.JDialog
;
21 import javax
.swing
.JTextArea
;
22 import javax
.swing
.JButton
;
23 import java
.awt
.FlowLayout
;
24 import java
.awt
.event
.ActionEvent
;
25 import java
.awt
.event
.ActionListener
;
26 import javax
.swing
.JScrollPane
;
31 Dialog for Long Text generation.
32 @since PackageEditor 1.0
34 public class GenLongTextDialog
extends JDialog
implements ActionListener
{
39 private static final long serialVersionUID
= 1L;
41 private JPanel jContentPane
= null;
42 private JPanel jPanelContentEast
= null;
43 private JPanel jPanelContentCenter
= null;
44 private JButton jButtonCancel
= null;
45 private JButton jButtonOk
= null;
46 private JTextArea jTextArea
= null;
49 private JScrollPane jScrollPane
= null;
53 public void actionPerformed(ActionEvent arg0
) {
55 if (arg0
.getSource() == jButtonOk
){
60 if (arg0
.getSource() == jButtonCancel
){
66 * This method initializes jPanel
68 * @return javax.swing.JPanel
70 private JPanel
getJPanelContentEast() {
71 if (jPanelContentEast
== null) {
72 FlowLayout flowLayout
= new FlowLayout();
73 flowLayout
.setVgap(5);
74 flowLayout
.setAlignment(java
.awt
.FlowLayout
.RIGHT
);
75 jPanelContentEast
= new JPanel();
76 jPanelContentEast
.setLayout(flowLayout
);
77 jPanelContentEast
.setPreferredSize(new java
.awt
.Dimension(100,30));
78 jPanelContentEast
.add(getJButtonOk(), null);
79 jPanelContentEast
.add(getJButtonCancel(), null);
81 return jPanelContentEast
;
85 * This method initializes jPanel4
87 * @return javax.swing.JPanel
89 private JPanel
getJPanelContentCenter() {
90 if (jPanelContentCenter
== null) {
91 jPanelContentCenter
= new JPanel();
92 jPanelContentCenter
.setLayout(new FlowLayout());
93 jPanelContentCenter
.add(getJScrollPane(), null);
96 return jPanelContentCenter
;
100 * This method initializes jButton
102 * @return javax.swing.JButton
104 private JButton
getJButtonCancel() {
105 if (jButtonCancel
== null) {
106 jButtonCancel
= new JButton();
107 jButtonCancel
.setPreferredSize(new java
.awt
.Dimension(80,20));
108 jButtonCancel
.setText("Cancel");
109 jButtonCancel
.addActionListener(this);
111 return jButtonCancel
;
115 * This method initializes jButton2
117 * @return javax.swing.JButton
119 private JButton
getJButtonOk() {
120 if (jButtonOk
== null) {
121 jButtonOk
= new JButton();
122 jButtonOk
.setPreferredSize(new java
.awt
.Dimension(80,20));
123 jButtonOk
.setText("Ok");
124 jButtonOk
.setActionCommand("GenGuidValue");
125 jButtonOk
.addActionListener(this);
131 * This method initializes jScrollPane
133 * @return javax.swing.JScrollPane
135 private JScrollPane
getJScrollPane() {
136 if (jScrollPane
== null) {
137 jScrollPane
= new JScrollPane();
138 jScrollPane
.setPreferredSize(new java
.awt
.Dimension(600,40));
139 jScrollPane
.setViewportView(getJTextArea());
144 private JTextArea
getJTextArea() {
145 if (jTextArea
== null) {
146 jTextArea
= new JTextArea();
147 // jTextArea.setBounds(new java.awt.Rectangle(40,20,300,54));
154 public String
getText(){
156 return jTextArea
.getText();
159 public void setText(String s
){
160 jTextArea
.setText(s
);
163 * This is the default constructor
165 public GenLongTextDialog() {
170 public GenLongTextDialog(ActionListener i
){
172 jButtonOk
.addActionListener(i
);
177 * This method initializes this
181 private void initialize() {
182 this.setSize(620, 120);
183 this.setDefaultCloseOperation(javax
.swing
.WindowConstants
.DISPOSE_ON_CLOSE
);
185 this.setTitle("Text Content");
186 this.setContentPane(getJContentPane());
191 * This method initializes jContentPane
193 * @return javax.swing.JPanel
195 private JPanel
getJContentPane() {
196 if (jContentPane
== null) {
197 jContentPane
= new JPanel();
198 jContentPane
.setLayout(new BorderLayout());
199 jContentPane
.add(getJPanelContentEast(), java
.awt
.BorderLayout
.SOUTH
);
200 jContentPane
.add(getJPanelContentCenter(), java
.awt
.BorderLayout
.CENTER
);
206 Start the window at the center of screen
209 protected void centerWindow(int intWidth
, int intHeight
) {
210 Dimension d
= Toolkit
.getDefaultToolkit().getScreenSize();
211 this.setLocation((d
.width
- intWidth
) / 2, (d
.height
- intHeight
) / 2);
215 Start the window at the center of screen
218 protected void centerWindow() {
219 centerWindow(this.getSize().width
, this.getSize().height
);
224 } // @jve:decl-index=0:visual-constraint="10,10"