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
.JComponent
;
20 import javax
.swing
.JPanel
;
21 import javax
.swing
.JDialog
;
22 import javax
.swing
.JTextArea
;
23 import javax
.swing
.JButton
;
24 import javax
.swing
.KeyStroke
;
26 import java
.awt
.FlowLayout
;
27 import java
.awt
.event
.ActionEvent
;
28 import java
.awt
.event
.ActionListener
;
29 import java
.awt
.event
.KeyEvent
;
31 import javax
.swing
.JScrollPane
;
36 Dialog for Long Text generation.
37 @since PackageEditor 1.0
39 public class GenLongTextDialog
extends JDialog
implements ActionListener
{
44 private static final long serialVersionUID
= 1L;
46 private JPanel jContentPane
= null;
47 private JPanel jPanelContentEast
= null;
48 private JPanel jPanelContentCenter
= null;
49 private JButton jButtonCancel
= null;
50 private JButton jButtonOk
= null;
51 private JTextArea jTextArea
= null;
54 private JScrollPane jScrollPane
= null;
56 public void actionPerformed(ActionEvent arg0
) {
58 if (arg0
.getSource() == jButtonOk
){
63 if (arg0
.getSource() == jButtonCancel
){
69 * This method initializes jPanel
71 * @return javax.swing.JPanel
73 private JPanel
getJPanelContentEast() {
74 if (jPanelContentEast
== null) {
75 FlowLayout flowLayout
= new FlowLayout();
76 flowLayout
.setVgap(5);
77 flowLayout
.setAlignment(java
.awt
.FlowLayout
.RIGHT
);
78 jPanelContentEast
= new JPanel();
79 jPanelContentEast
.setLayout(flowLayout
);
80 jPanelContentEast
.setPreferredSize(new java
.awt
.Dimension(100,30));
81 jPanelContentEast
.add(getJButtonOk(), null);
82 jPanelContentEast
.add(getJButtonCancel(), null);
84 return jPanelContentEast
;
88 * This method initializes jPanel4
90 * @return javax.swing.JPanel
92 private JPanel
getJPanelContentCenter() {
93 if (jPanelContentCenter
== null) {
94 jPanelContentCenter
= new JPanel();
95 jPanelContentCenter
.setLayout(new FlowLayout());
96 jPanelContentCenter
.add(getJScrollPane(), null);
99 return jPanelContentCenter
;
103 * This method initializes jButton
105 * @return javax.swing.JButton
107 private JButton
getJButtonCancel() {
108 if (jButtonCancel
== null) {
109 jButtonCancel
= new JButton();
110 jButtonCancel
.setPreferredSize(new java
.awt
.Dimension(80,20));
111 jButtonCancel
.setText("Cancel");
112 jButtonCancel
.addActionListener(this);
113 jButtonCancel
.registerKeyboardAction(this, KeyStroke
.getKeyStroke(KeyEvent
.VK_ENTER
, 0, false), JComponent
.WHEN_FOCUSED
);
115 return jButtonCancel
;
119 * This method initializes jButton2
121 * @return javax.swing.JButton
123 private JButton
getJButtonOk() {
124 if (jButtonOk
== null) {
125 jButtonOk
= new JButton();
126 jButtonOk
.setPreferredSize(new java
.awt
.Dimension(80,20));
127 jButtonOk
.setText("Ok");
128 jButtonOk
.setActionCommand("GenGuidValue");
129 jButtonOk
.addActionListener(this);
135 * This method initializes jScrollPane
137 * @return javax.swing.JScrollPane
139 private JScrollPane
getJScrollPane() {
140 if (jScrollPane
== null) {
141 jScrollPane
= new JScrollPane();
142 jScrollPane
.setPreferredSize(new java
.awt
.Dimension(600,40));
143 jScrollPane
.setViewportView(getJTextArea());
148 private JTextArea
getJTextArea() {
149 if (jTextArea
== null) {
150 jTextArea
= new JTextArea();
151 // jTextArea.setBounds(new java.awt.Rectangle(40,20,300,54));
158 public String
getText(){
160 return jTextArea
.getText();
163 public void setText(String s
){
164 jTextArea
.setText(s
);
167 * This is the default constructor
169 public GenLongTextDialog() {
174 public GenLongTextDialog(ActionListener i
){
176 jButtonOk
.addActionListener(i
);
177 jButtonOk
.registerKeyboardAction(i
, KeyStroke
.getKeyStroke(KeyEvent
.VK_ENTER
, 0, false), JComponent
.WHEN_FOCUSED
);
181 * This method initializes this
185 private void initialize() {
186 this.setSize(620, 120);
187 this.setDefaultCloseOperation(javax
.swing
.WindowConstants
.DISPOSE_ON_CLOSE
);
189 this.setTitle("Text Content");
190 this.setContentPane(getJContentPane());
195 * This method initializes jContentPane
197 * @return javax.swing.JPanel
199 private JPanel
getJContentPane() {
200 if (jContentPane
== null) {
201 jContentPane
= new JPanel();
202 jContentPane
.setLayout(new BorderLayout());
203 jContentPane
.add(getJPanelContentEast(), java
.awt
.BorderLayout
.SOUTH
);
204 jContentPane
.add(getJPanelContentCenter(), java
.awt
.BorderLayout
.CENTER
);
210 Start the window at the center of screen
213 protected void centerWindow(int intWidth
, int intHeight
) {
214 Dimension d
= Toolkit
.getDefaultToolkit().getScreenSize();
215 this.setLocation((d
.width
- intWidth
) / 2, (d
.height
- intHeight
) / 2);
219 Start the window at the center of screen
222 protected void centerWindow() {
223 centerWindow(this.getSize().width
, this.getSize().height
);
228 } // @jve:decl-index=0:visual-constraint="10,10"