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 9.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275
  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. {
  87. bgSelect = new javax.swing.ButtonGroup();
  88. jScrollPane1 = new javax.swing.JScrollPane();
  89. taCommunication = new javax.swing.JTextArea();
  90. tfMessage = new javax.swing.JTextField();
  91. btSend = new javax.swing.JButton();
  92. tfPort = new javax.swing.JTextField();
  93. lbPort = new javax.swing.JLabel();
  94. lbIP = new javax.swing.JLabel();
  95. tfIP = new javax.swing.JTextField();
  96. btConnect = new javax.swing.JButton();
  97. rbClient = new javax.swing.JRadioButton();
  98. rbServer = new javax.swing.JRadioButton();
  99. jSeparator2 = new javax.swing.JSeparator();
  100. setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
  101. setTitle("ICQ 0.1 xD");
  102. taCommunication.setColumns(20);
  103. taCommunication.setRows(5);
  104. jScrollPane1.setViewportView(taCommunication);
  105. btSend.setText("send");
  106. tfPort.setText("45000");
  107. tfPort.setToolTipText("");
  108. lbPort.setText("Port:");
  109. lbPort.setToolTipText("");
  110. lbIP.setText("IP:");
  111. tfIP.setText("127.0.0.1");
  112. btConnect.setText("connect");
  113. btConnect.setToolTipText("");
  114. bgSelect.add(rbClient);
  115. rbClient.setSelected(true);
  116. rbClient.setText("Client");
  117. rbClient.addActionListener(new java.awt.event.ActionListener()
  118. {
  119. public void actionPerformed(java.awt.event.ActionEvent evt)
  120. {
  121. rbClientActionPerformed(evt);
  122. }
  123. });
  124. bgSelect.add(rbServer);
  125. rbServer.setText("Server");
  126. rbServer.addActionListener(new java.awt.event.ActionListener()
  127. {
  128. public void actionPerformed(java.awt.event.ActionEvent evt)
  129. {
  130. rbServerActionPerformed(evt);
  131. }
  132. });
  133. javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
  134. getContentPane().setLayout(layout);
  135. layout.setHorizontalGroup(
  136. layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  137. .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
  138. .addContainerGap()
  139. .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
  140. .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
  141. .addComponent(lbPort)
  142. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  143. .addComponent(tfPort, javax.swing.GroupLayout.PREFERRED_SIZE, 61, javax.swing.GroupLayout.PREFERRED_SIZE)
  144. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  145. .addComponent(lbIP)
  146. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  147. .addComponent(tfIP, javax.swing.GroupLayout.PREFERRED_SIZE, 191, javax.swing.GroupLayout.PREFERRED_SIZE)
  148. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 247, Short.MAX_VALUE)
  149. .addComponent(btConnect))
  150. .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
  151. .addComponent(rbClient, javax.swing.GroupLayout.PREFERRED_SIZE, 64, javax.swing.GroupLayout.PREFERRED_SIZE)
  152. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  153. .addComponent(rbServer)
  154. .addGap(0, 0, Short.MAX_VALUE))
  155. .addComponent(jScrollPane1)
  156. .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
  157. .addComponent(tfMessage)
  158. .addGap(18, 18, 18)
  159. .addComponent(btSend)))
  160. .addContainerGap())
  161. .addComponent(jSeparator2)
  162. );
  163. layout.setVerticalGroup(
  164. layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  165. .addGroup(layout.createSequentialGroup()
  166. .addContainerGap()
  167. .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 243, Short.MAX_VALUE)
  168. .addGap(18, 18, 18)
  169. .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
  170. .addComponent(tfMessage, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)
  171. .addComponent(btSend))
  172. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
  173. .addComponent(jSeparator2, javax.swing.GroupLayout.PREFERRED_SIZE, 6, javax.swing.GroupLayout.PREFERRED_SIZE)
  174. .addGap(1, 1, 1)
  175. .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
  176. .addComponent(rbServer)
  177. .addComponent(rbClient))
  178. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
  179. .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
  180. .addComponent(lbPort)
  181. .addComponent(tfPort, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
  182. .addComponent(tfIP, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
  183. .addComponent(lbIP)
  184. .addComponent(btConnect))
  185. .addContainerGap())
  186. );
  187. pack();
  188. setLocationRelativeTo(null);
  189. }// </editor-fold>//GEN-END:initComponents
  190. private void rbClientActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_rbClientActionPerformed
  191. // TODO add your handling code here:
  192. }//GEN-LAST:event_rbClientActionPerformed
  193. private void rbServerActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_rbServerActionPerformed
  194. // TODO add your handling code here:
  195. }//GEN-LAST:event_rbServerActionPerformed
  196. /**
  197. * @param args the command line arguments
  198. */
  199. public static void main(String args[]) {
  200. /* Set the Nimbus look and feel */
  201. //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
  202. /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
  203. * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
  204. */
  205. try {
  206. for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
  207. if ("Nimbus".equals(info.getName())) {
  208. javax.swing.UIManager.setLookAndFeel(info.getClassName());
  209. break;
  210. }
  211. }
  212. } catch (ClassNotFoundException ex) {
  213. java.util.logging.Logger.getLogger(ChatView.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  214. } catch (InstantiationException ex) {
  215. java.util.logging.Logger.getLogger(ChatView.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  216. } catch (IllegalAccessException ex) {
  217. java.util.logging.Logger.getLogger(ChatView.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  218. } catch (javax.swing.UnsupportedLookAndFeelException ex) {
  219. java.util.logging.Logger.getLogger(ChatView.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  220. }
  221. //</editor-fold>
  222. /* Create and display the form */
  223. java.awt.EventQueue.invokeLater(new Runnable() {
  224. public void run() {
  225. new ChatView().setVisible(true);
  226. }
  227. });
  228. }
  229. // Variables declaration - do not modify//GEN-BEGIN:variables
  230. private javax.swing.ButtonGroup bgSelect;
  231. private javax.swing.JButton btConnect;
  232. private javax.swing.JButton btSend;
  233. private javax.swing.JScrollPane jScrollPane1;
  234. private javax.swing.JSeparator jSeparator2;
  235. private javax.swing.JLabel lbIP;
  236. private javax.swing.JLabel lbPort;
  237. private javax.swing.JRadioButton rbClient;
  238. private javax.swing.JRadioButton rbServer;
  239. private javax.swing.JTextArea taCommunication;
  240. private javax.swing.JTextField tfIP;
  241. private javax.swing.JTextField tfMessage;
  242. private javax.swing.JTextField tfPort;
  243. // End of variables declaration//GEN-END:variables
  244. }