You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

ChatView.java 10KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268
  1. /*
  2. * To change this license header, choose License Headers in Project Properties.
  3. * To change this template file, choose Tools | Templates
  4. * and open the template in the editor.
  5. */
  6. package chatprogramm.view;
  7. /**
  8. *
  9. * @author max
  10. */
  11. public class ChatView extends javax.swing.JFrame {
  12. /**
  13. * @return the rbClient
  14. */
  15. public javax.swing.JRadioButton getRbClient() {
  16. return rbClient;
  17. }
  18. /**
  19. * @return the rbServer
  20. */
  21. public javax.swing.JRadioButton getRbServer() {
  22. return rbServer;
  23. }
  24. /**
  25. * @return the btConnect
  26. */
  27. public javax.swing.JButton getBtConnect() {
  28. return btConnect;
  29. }
  30. /**
  31. * @return the btSend
  32. */
  33. public javax.swing.JButton getBtSend() {
  34. return btSend;
  35. }
  36. /**
  37. * @return the lbIP
  38. */
  39. public javax.swing.JLabel getLbIP() {
  40. return lbIP;
  41. }
  42. /**
  43. * @return the lbPort
  44. */
  45. public javax.swing.JLabel getLbPort() {
  46. return lbPort;
  47. }
  48. /**
  49. * @return the taCommunication
  50. */
  51. public javax.swing.JTextArea getTaCommunication() {
  52. return taCommunication;
  53. }
  54. /**
  55. * @return the tfIP
  56. */
  57. public javax.swing.JTextField getTfIP() {
  58. return tfIP;
  59. }
  60. /**
  61. * @return the tfMessage
  62. */
  63. public javax.swing.JTextField getTfMessage() {
  64. return tfMessage;
  65. }
  66. /**
  67. * @return the tfPort
  68. */
  69. public javax.swing.JTextField getTfPort() {
  70. return tfPort;
  71. }
  72. /**
  73. * Creates new form ChatView
  74. */
  75. public ChatView() {
  76. initComponents();
  77. }
  78. /**
  79. * This method is called from within the constructor to initialize the form.
  80. * WARNING: Do NOT modify this code. The content of this method is always
  81. * regenerated by the Form Editor.
  82. */
  83. @SuppressWarnings("unchecked")
  84. // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
  85. private void initComponents() {
  86. bgSelect = new javax.swing.ButtonGroup();
  87. jScrollPane1 = new javax.swing.JScrollPane();
  88. taCommunication = new javax.swing.JTextArea();
  89. tfMessage = new javax.swing.JTextField();
  90. btSend = new javax.swing.JButton();
  91. tfPort = new javax.swing.JTextField();
  92. lbPort = new javax.swing.JLabel();
  93. lbIP = new javax.swing.JLabel();
  94. tfIP = new javax.swing.JTextField();
  95. btConnect = new javax.swing.JButton();
  96. rbClient = new javax.swing.JRadioButton();
  97. rbServer = new javax.swing.JRadioButton();
  98. jSeparator2 = new javax.swing.JSeparator();
  99. setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
  100. taCommunication.setColumns(20);
  101. taCommunication.setRows(5);
  102. jScrollPane1.setViewportView(taCommunication);
  103. btSend.setText("send");
  104. tfPort.setText("3210");
  105. tfPort.setToolTipText("");
  106. lbPort.setText("Port:");
  107. lbPort.setToolTipText("");
  108. lbIP.setText("IP:");
  109. tfIP.setText("127.0.0.1");
  110. btConnect.setText("connect");
  111. btConnect.setToolTipText("");
  112. bgSelect.add(rbClient);
  113. rbClient.setSelected(true);
  114. rbClient.setText("Client");
  115. rbClient.addActionListener(new java.awt.event.ActionListener() {
  116. public void actionPerformed(java.awt.event.ActionEvent evt) {
  117. rbClientActionPerformed(evt);
  118. }
  119. });
  120. bgSelect.add(rbServer);
  121. rbServer.setText("Server");
  122. rbServer.addActionListener(new java.awt.event.ActionListener() {
  123. public void actionPerformed(java.awt.event.ActionEvent evt) {
  124. rbServerActionPerformed(evt);
  125. }
  126. });
  127. javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
  128. getContentPane().setLayout(layout);
  129. layout.setHorizontalGroup(
  130. layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  131. .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
  132. .addContainerGap()
  133. .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
  134. .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
  135. .addComponent(lbPort)
  136. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  137. .addComponent(tfPort, javax.swing.GroupLayout.PREFERRED_SIZE, 61, javax.swing.GroupLayout.PREFERRED_SIZE)
  138. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  139. .addComponent(lbIP)
  140. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  141. .addComponent(tfIP, javax.swing.GroupLayout.PREFERRED_SIZE, 191, javax.swing.GroupLayout.PREFERRED_SIZE)
  142. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 34, Short.MAX_VALUE)
  143. .addComponent(btConnect))
  144. .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
  145. .addComponent(rbClient, javax.swing.GroupLayout.PREFERRED_SIZE, 64, javax.swing.GroupLayout.PREFERRED_SIZE)
  146. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  147. .addComponent(rbServer)
  148. .addGap(0, 0, Short.MAX_VALUE))
  149. .addComponent(jScrollPane1)
  150. .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
  151. .addComponent(tfMessage)
  152. .addGap(18, 18, 18)
  153. .addComponent(btSend)))
  154. .addContainerGap())
  155. .addComponent(jSeparator2)
  156. );
  157. layout.setVerticalGroup(
  158. layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  159. .addGroup(layout.createSequentialGroup()
  160. .addContainerGap()
  161. .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 134, Short.MAX_VALUE)
  162. .addGap(18, 18, 18)
  163. .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
  164. .addComponent(tfMessage, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)
  165. .addComponent(btSend))
  166. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
  167. .addComponent(jSeparator2, javax.swing.GroupLayout.PREFERRED_SIZE, 6, javax.swing.GroupLayout.PREFERRED_SIZE)
  168. .addGap(1, 1, 1)
  169. .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
  170. .addComponent(rbServer)
  171. .addComponent(rbClient))
  172. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
  173. .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
  174. .addComponent(lbPort)
  175. .addComponent(tfPort, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
  176. .addComponent(tfIP, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
  177. .addComponent(lbIP)
  178. .addComponent(btConnect))
  179. .addContainerGap())
  180. );
  181. pack();
  182. }// </editor-fold>//GEN-END:initComponents
  183. private void rbClientActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_rbClientActionPerformed
  184. // TODO add your handling code here:
  185. }//GEN-LAST:event_rbClientActionPerformed
  186. private void rbServerActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_rbServerActionPerformed
  187. // TODO add your handling code here:
  188. }//GEN-LAST:event_rbServerActionPerformed
  189. /**
  190. * @param args the command line arguments
  191. */
  192. public static void main(String args[]) {
  193. /* Set the Nimbus look and feel */
  194. //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
  195. /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
  196. * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
  197. */
  198. try {
  199. for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
  200. if ("Nimbus".equals(info.getName())) {
  201. javax.swing.UIManager.setLookAndFeel(info.getClassName());
  202. break;
  203. }
  204. }
  205. } catch (ClassNotFoundException ex) {
  206. java.util.logging.Logger.getLogger(ChatView.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  207. } catch (InstantiationException ex) {
  208. java.util.logging.Logger.getLogger(ChatView.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  209. } catch (IllegalAccessException ex) {
  210. java.util.logging.Logger.getLogger(ChatView.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  211. } catch (javax.swing.UnsupportedLookAndFeelException ex) {
  212. java.util.logging.Logger.getLogger(ChatView.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  213. }
  214. //</editor-fold>
  215. /* Create and display the form */
  216. java.awt.EventQueue.invokeLater(new Runnable() {
  217. public void run() {
  218. new ChatView().setVisible(true);
  219. }
  220. });
  221. }
  222. // Variables declaration - do not modify//GEN-BEGIN:variables
  223. private javax.swing.ButtonGroup bgSelect;
  224. private javax.swing.JButton btConnect;
  225. private javax.swing.JButton btSend;
  226. private javax.swing.JScrollPane jScrollPane1;
  227. private javax.swing.JSeparator jSeparator2;
  228. private javax.swing.JLabel lbIP;
  229. private javax.swing.JLabel lbPort;
  230. private javax.swing.JRadioButton rbClient;
  231. private javax.swing.JRadioButton rbServer;
  232. private javax.swing.JTextArea taCommunication;
  233. private javax.swing.JTextField tfIP;
  234. private javax.swing.JTextField tfMessage;
  235. private javax.swing.JTextField tfPort;
  236. // End of variables declaration//GEN-END:variables
  237. }