001: /*
002: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003: *
004: * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005: *
006: * The contents of this file are subject to the terms of either the GNU
007: * General Public License Version 2 only ("GPL") or the Common
008: * Development and Distribution License("CDDL") (collectively, the
009: * "License"). You may not use this file except in compliance with the
010: * License. You can obtain a copy of the License at
011: * http://www.netbeans.org/cddl-gplv2.html
012: * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013: * specific language governing permissions and limitations under the
014: * License. When distributing the software, include this License Header
015: * Notice in each file and include the License file at
016: * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
017: * particular file as subject to the "Classpath" exception as provided
018: * by Sun in the GPL Version 2 section of the License file that
019: * accompanied this code. If applicable, add the following below the
020: * License Header, with the fields enclosed by brackets [] replaced by
021: * your own identifying information:
022: * "Portions Copyrighted [year] [name of copyright owner]"
023: *
024: * Contributor(s):
025: *
026: * The Original Software is NetBeans. The Initial Developer of the Original
027: * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
028: * Microsystems, Inc. All Rights Reserved.
029: *
030: * If you wish your version of this file to be governed by only the CDDL
031: * or only the GPL Version 2, indicate your decision by adding
032: * "[Contributor] elects to include this software in this distribution
033: * under the [CDDL or GPL Version 2] license." If you do not indicate a
034: * single choice of license, a recipient has the option to distribute
035: * your version of this file under either the CDDL, the GPL Version 2 or
036: * to extend the choice of license to its licensees as provided above.
037: * However, if you add GPL Version 2 code and therefore, elected the GPL
038: * Version 2 license, then the option applies only if the new code is
039: * made subject to such option by the copyright holder.
040: */
041:
042: package com.sun.errorhandler;
043:
044: /*
045: * DebugClientWindow.java
046: * Created on January 6, 2004, 1:21 PM
047: */
048:
049: /**
050: * @author Winston Prakash
051: */
052: public class DebugClientTestWindow extends javax.swing.JFrame {
053: DebugClientTestThread clientThread = null;
054:
055: /** Creates new form ServerWindow */
056: public DebugClientTestWindow() {
057: initComponents();
058: }
059:
060: /** This method is called from within the constructor to
061: * initialize the form.
062: * WARNING: Do NOT modify this code. The content of this method is
063: * always regenerated by the Form Editor.
064: */
065: private void initComponents() {//GEN-BEGIN:initComponents
066: java.awt.GridBagConstraints gridBagConstraints;
067:
068: mainPanel = new javax.swing.JPanel();
069: scrollPane = new javax.swing.JScrollPane();
070: textArea = new javax.swing.JTextArea();
071: messagePanel = new javax.swing.JPanel();
072: messageField = new javax.swing.JTextField();
073: buttonPanel = new javax.swing.JPanel();
074: exitButton = new javax.swing.JButton();
075: sendButton = new javax.swing.JButton();
076:
077: setTitle("Client Window");
078: addWindowListener(new java.awt.event.WindowAdapter() {
079: public void windowClosing(java.awt.event.WindowEvent evt) {
080: exitForm(evt);
081: }
082: });
083:
084: mainPanel.setLayout(new java.awt.BorderLayout());
085:
086: textArea.setColumns(35);
087: textArea.setEditable(false);
088: textArea.setLineWrap(true);
089: textArea.setRows(15);
090: textArea.setWrapStyleWord(true);
091: scrollPane.setViewportView(textArea);
092:
093: mainPanel.add(scrollPane, java.awt.BorderLayout.CENTER);
094:
095: getContentPane().add(mainPanel, java.awt.BorderLayout.CENTER);
096:
097: messagePanel.setLayout(new java.awt.BorderLayout());
098:
099: messagePanel.setBorder(new javax.swing.border.EmptyBorder(
100: new java.awt.Insets(5, 1, 1, 1)));
101: messagePanel.add(messageField, java.awt.BorderLayout.NORTH);
102:
103: buttonPanel.setLayout(new java.awt.GridBagLayout());
104:
105: buttonPanel.setBorder(new javax.swing.border.EmptyBorder(
106: new java.awt.Insets(5, 1, 1, 1)));
107: exitButton.setText("Exit");
108: exitButton
109: .addActionListener(new java.awt.event.ActionListener() {
110: public void actionPerformed(
111: java.awt.event.ActionEvent evt) {
112: exitButtonActionPerformed(evt);
113: }
114: });
115:
116: gridBagConstraints = new java.awt.GridBagConstraints();
117: gridBagConstraints.gridx = 1;
118: gridBagConstraints.gridy = 0;
119: buttonPanel.add(exitButton, gridBagConstraints);
120:
121: sendButton.setText("Send");
122: sendButton
123: .addActionListener(new java.awt.event.ActionListener() {
124: public void actionPerformed(
125: java.awt.event.ActionEvent evt) {
126: sendButtonActionPerformed(evt);
127: }
128: });
129:
130: gridBagConstraints = new java.awt.GridBagConstraints();
131: gridBagConstraints.gridx = 0;
132: gridBagConstraints.gridy = 0;
133: buttonPanel.add(sendButton, gridBagConstraints);
134:
135: messagePanel.add(buttonPanel, java.awt.BorderLayout.EAST);
136:
137: getContentPane().add(messagePanel, java.awt.BorderLayout.SOUTH);
138:
139: setBounds(500, 100, 400, 300);
140: }//GEN-END:initComponents
141:
142: private void sendButtonActionPerformed(
143: java.awt.event.ActionEvent evt) {//GEN-FIRST:event_sendButtonActionPerformed
144: if (messageField.getText() != null
145: || !messageField.getText().equals("")) {
146: if (clientThread.isConnected())
147: clientThread.sendMessage(messageField.getText());
148: messageField.setText("");
149: }
150: }//GEN-LAST:event_sendButtonActionPerformed
151:
152: private void exitButtonActionPerformed(
153: java.awt.event.ActionEvent evt) {//GEN-FIRST:event_exitButtonActionPerformed
154: System.exit(0);
155: }//GEN-LAST:event_exitButtonActionPerformed
156:
157: public void connectSocket() {
158: clientThread = new DebugClientTestThread(textArea);
159: clientThread.start();
160: }
161:
162: /** Exit the Application */
163: private void exitForm(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_exitForm
164: clientThread.disconnect();
165: System.exit(0);
166: }//GEN-LAST:event_exitForm
167:
168: /**
169: * @param args the command line arguments
170: */
171: public static void main(String args[]) {
172: DebugClientTestWindow clientWindow = new DebugClientTestWindow();
173: clientWindow.connectSocket();
174: clientWindow.show();
175: }
176:
177: // Variables declaration - do not modify//GEN-BEGIN:variables
178: private javax.swing.JPanel buttonPanel;
179: private javax.swing.JButton exitButton;
180: private javax.swing.JPanel mainPanel;
181: private javax.swing.JTextField messageField;
182: private javax.swing.JPanel messagePanel;
183: private javax.swing.JScrollPane scrollPane;
184: private javax.swing.JButton sendButton;
185: private javax.swing.JTextArea textArea;
186: // End of variables declaration//GEN-END:variables
187:
188: }
|