1 6 7 package com.quikj.client.beans; 8 9 import java.awt.*; 10 11 15 public class TextAreaDialog extends java.awt.Dialog 16 { 17 18 19 public TextAreaDialog(java.awt.Frame parent, 20 String title, String label, String button_label, String text) 21 { 22 super(parent, true); 23 initComponents(); 24 25 setTitle(title); 26 textLabel.setText(label); 27 dismissButton.setLabel(button_label); 28 textAreaField.setText(text); 29 30 31 Rectangle pbounds = parent.getBounds(); 32 Point mid = new Point(pbounds.x + (pbounds.width/2), pbounds.y + (pbounds.height/2)); 33 Rectangle bounds = getBounds(); 34 int x = mid.x - (bounds.width/2); 35 int y = mid.y - (bounds.height/2); 36 if (x < 0) x = pbounds.x; 37 if (y < 0) y = pbounds.y; 38 setBounds(x, y, bounds.width, bounds.height); 39 40 show(); 41 } 42 43 48 private void initComponents() { 50 java.awt.GridBagConstraints gridBagConstraints; 51 52 panel1 = new java.awt.Panel (); 53 textLabel = new java.awt.Label (); 54 textAreaField = new java.awt.TextArea (); 55 dismissButton = new java.awt.Button (); 56 57 setBackground(java.awt.Color.white); 58 setModal(true); 59 setTitle("Text area"); 60 addWindowListener(new java.awt.event.WindowAdapter () 61 { 62 public void windowClosing(java.awt.event.WindowEvent evt) 63 { 64 closeDialog(evt); 65 } 66 }); 67 68 panel1.setLayout(new java.awt.GridBagLayout ()); 69 70 textLabel.setText("Label"); 71 gridBagConstraints = new java.awt.GridBagConstraints (); 72 gridBagConstraints.gridx = 0; 73 gridBagConstraints.gridy = 0; 74 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 75 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; 76 gridBagConstraints.insets = new java.awt.Insets (5, 5, 0, 0); 77 panel1.add(textLabel, gridBagConstraints); 78 79 textAreaField.setBackground(new java.awt.Color (255, 255, 255)); 80 textAreaField.setFont(new java.awt.Font ("Monospaced", 0, 12)); 81 textAreaField.setEditable(false); 82 gridBagConstraints = new java.awt.GridBagConstraints (); 83 gridBagConstraints.gridx = 0; 84 gridBagConstraints.gridy = 1; 85 gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; 86 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; 87 gridBagConstraints.weightx = 100.0; 88 gridBagConstraints.weighty = 100.0; 89 gridBagConstraints.insets = new java.awt.Insets (0, 5, 0, 0); 90 panel1.add(textAreaField, gridBagConstraints); 91 92 dismissButton.setLabel("button1"); 93 dismissButton.addActionListener(new java.awt.event.ActionListener () 94 { 95 public void actionPerformed(java.awt.event.ActionEvent evt) 96 { 97 dismissButtonActionPerformed(evt); 98 } 99 }); 100 101 gridBagConstraints = new java.awt.GridBagConstraints (); 102 gridBagConstraints.gridx = 0; 103 gridBagConstraints.gridy = 2; 104 gridBagConstraints.insets = new java.awt.Insets (10, 0, 10, 0); 105 panel1.add(dismissButton, gridBagConstraints); 106 107 add(panel1, java.awt.BorderLayout.CENTER); 108 109 pack(); 110 } 112 private void dismissButtonActionPerformed(java.awt.event.ActionEvent evt) { setVisible(false); 116 dispose(); 117 } 119 120 private void closeDialog(java.awt.event.WindowEvent evt) { setVisible(false); 122 dispose(); 123 } 125 128 public static void main(String args[]) 129 { 130 new TextAreaDialog(new java.awt.Frame (), "Test", "List", "Close", "hello").show(); 131 } 132 133 134 135 private java.awt.Button dismissButton; 137 private java.awt.TextArea textAreaField; 138 private java.awt.Label textLabel; 139 private java.awt.Panel panel1; 140 142 } 143 | Popular Tags |