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
.JFrame
;
21 import javax
.swing
.JPanel
;
22 import javax
.swing
.JDialog
;
23 import javax
.swing
.JTextArea
;
24 import javax
.swing
.JButton
;
25 import javax
.swing
.KeyStroke
;
27 import java
.awt
.FlowLayout
;
28 import java
.awt
.event
.ActionEvent
;
29 import java
.awt
.event
.ActionListener
;
30 import java
.awt
.event
.KeyEvent
;
32 import javax
.swing
.JScrollPane
;
37 Dialog for Long Text generation.
38 @since PackageEditor 1.0
40 public class GenLongTextDialog
extends JDialog
implements ActionListener
{
45 private static final long serialVersionUID
= 1L;
47 private JPanel jContentPane
= null;
48 private JPanel jPanelContentEast
= null;
49 private JPanel jPanelContentCenter
= null;
50 private JButton jButtonCancel
= null;
51 private JButton jButtonOk
= null;
52 private JTextArea jTextArea
= null;
55 private JScrollPane jScrollPane
= null;
57 public void actionPerformed(ActionEvent arg0
) {
59 if (arg0
.getSource() == jButtonOk
){
64 if (arg0
.getSource() == jButtonCancel
){
70 * This method initializes jPanel
72 * @return javax.swing.JPanel
74 private JPanel
getJPanelContentEast() {
75 if (jPanelContentEast
== null) {
76 FlowLayout flowLayout
= new FlowLayout();
77 flowLayout
.setVgap(5);
78 flowLayout
.setAlignment(java
.awt
.FlowLayout
.RIGHT
);
79 jPanelContentEast
= new JPanel();
80 jPanelContentEast
.setLayout(flowLayout
);
81 jPanelContentEast
.setPreferredSize(new java
.awt
.Dimension(100,30));
82 jPanelContentEast
.add(getJButtonOk(), null);
83 jPanelContentEast
.add(getJButtonCancel(), null);
85 return jPanelContentEast
;
89 * This method initializes jPanel4
91 * @return javax.swing.JPanel
93 private JPanel
getJPanelContentCenter() {
94 if (jPanelContentCenter
== null) {
95 jPanelContentCenter
= new JPanel();
96 jPanelContentCenter
.setLayout(new FlowLayout());
97 jPanelContentCenter
.add(getJScrollPane(), null);
100 return jPanelContentCenter
;
104 * This method initializes jButton
106 * @return javax.swing.JButton
108 private JButton
getJButtonCancel() {
109 if (jButtonCancel
== null) {
110 jButtonCancel
= new JButton();
111 jButtonCancel
.setPreferredSize(new java
.awt
.Dimension(80,20));
112 jButtonCancel
.setText("Cancel");
113 jButtonCancel
.addActionListener(this);
114 jButtonCancel
.registerKeyboardAction(this, KeyStroke
.getKeyStroke(KeyEvent
.VK_ENTER
, 0, false), JComponent
.WHEN_FOCUSED
);
116 return jButtonCancel
;
120 * This method initializes jButton2
122 * @return javax.swing.JButton
124 private JButton
getJButtonOk() {
125 if (jButtonOk
== null) {
126 jButtonOk
= new JButton();
127 jButtonOk
.setPreferredSize(new java
.awt
.Dimension(80,20));
128 jButtonOk
.setText("Ok");
129 jButtonOk
.setActionCommand("GenGuidValue");
130 jButtonOk
.addActionListener(this);
136 * This method initializes jScrollPane
138 * @return javax.swing.JScrollPane
140 private JScrollPane
getJScrollPane() {
141 if (jScrollPane
== null) {
142 jScrollPane
= new JScrollPane();
143 jScrollPane
.setPreferredSize(new java
.awt
.Dimension(600,40));
144 jScrollPane
.setViewportView(getJTextArea());
149 private JTextArea
getJTextArea() {
150 if (jTextArea
== null) {
151 jTextArea
= new JTextArea();
152 // jTextArea.setBounds(new java.awt.Rectangle(40,20,300,54));
159 public String
getText(){
161 return jTextArea
.getText();
164 public void setText(String s
){
165 jTextArea
.setText(s
);
168 * This is the default constructor
170 public GenLongTextDialog(JFrame frame
) {
175 public GenLongTextDialog(ActionListener i
, JFrame frame
){
177 jButtonOk
.addActionListener(i
);
178 jButtonOk
.registerKeyboardAction(i
, KeyStroke
.getKeyStroke(KeyEvent
.VK_ENTER
, 0, false), JComponent
.WHEN_FOCUSED
);
182 * This method initializes this
186 private void initialize() {
187 this.setSize(620, 120);
188 this.setDefaultCloseOperation(javax
.swing
.WindowConstants
.DISPOSE_ON_CLOSE
);
190 this.setTitle("Text Content");
191 this.setContentPane(getJContentPane());
196 * This method initializes jContentPane
198 * @return javax.swing.JPanel
200 private JPanel
getJContentPane() {
201 if (jContentPane
== null) {
202 jContentPane
= new JPanel();
203 jContentPane
.setLayout(new BorderLayout());
204 jContentPane
.add(getJPanelContentEast(), java
.awt
.BorderLayout
.SOUTH
);
205 jContentPane
.add(getJPanelContentCenter(), java
.awt
.BorderLayout
.CENTER
);
211 Start the window at the center of screen
214 protected void centerWindow(int intWidth
, int intHeight
) {
215 Dimension d
= Toolkit
.getDefaultToolkit().getScreenSize();
216 this.setLocation((d
.width
- intWidth
) / 2, (d
.height
- intHeight
) / 2);
220 Start the window at the center of screen
223 protected void centerWindow() {
224 centerWindow(this.getSize().width
, this.getSize().height
);
229 } // @jve:decl-index=0:visual-constraint="10,10"