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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285
  1. /*
  2. * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
  3. * Click nbfs://nbhost/SystemFileSystem/Templates/GUIForms/JFrame.java to edit this template
  4. */
  5. package ChatProgramm.view;
  6. /**
  7. *
  8. * @author ahren
  9. */
  10. public class ChatView extends javax.swing.JFrame
  11. {
  12. /**
  13. * Creates new form ChatView
  14. */
  15. public ChatView()
  16. {
  17. initComponents();
  18. }
  19. /**
  20. * This method is called from within the constructor to initialize the form.
  21. * WARNING: Do NOT modify this code. The content of this method is always
  22. * regenerated by the Form Editor.
  23. */
  24. @SuppressWarnings("unchecked")
  25. // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
  26. private void initComponents()
  27. {
  28. dialogChooseMode = new javax.swing.JDialog();
  29. lblMode = new javax.swing.JLabel();
  30. BtnServer = new javax.swing.JRadioButton();
  31. BtnClient = new javax.swing.JRadioButton();
  32. jPanel1 = new javax.swing.JPanel();
  33. BtnConnect = new javax.swing.JButton();
  34. BtnGrpMode = new javax.swing.ButtonGroup();
  35. tfNachricht = new javax.swing.JTextField();
  36. jScrollPane2 = new javax.swing.JScrollPane();
  37. txtChat = new javax.swing.JTextArea();
  38. dialogChooseMode.setMinimumSize(new java.awt.Dimension(278, 208));
  39. dialogChooseMode.getContentPane().setLayout(new java.awt.GridLayout(0, 1));
  40. lblMode.setText(" Choose your mode:");
  41. dialogChooseMode.getContentPane().add(lblMode);
  42. BtnGrpMode.add(BtnServer);
  43. BtnServer.setText("Server");
  44. BtnServer.addActionListener(new java.awt.event.ActionListener()
  45. {
  46. public void actionPerformed(java.awt.event.ActionEvent evt)
  47. {
  48. BtnServerActionPerformed(evt);
  49. }
  50. });
  51. dialogChooseMode.getContentPane().add(BtnServer);
  52. BtnGrpMode.add(BtnClient);
  53. BtnClient.setText("Client");
  54. BtnClient.addActionListener(new java.awt.event.ActionListener()
  55. {
  56. public void actionPerformed(java.awt.event.ActionEvent evt)
  57. {
  58. BtnClientActionPerformed(evt);
  59. }
  60. });
  61. dialogChooseMode.getContentPane().add(BtnClient);
  62. BtnConnect.setText("Connect");
  63. BtnConnect.addActionListener(new java.awt.event.ActionListener()
  64. {
  65. public void actionPerformed(java.awt.event.ActionEvent evt)
  66. {
  67. BtnConnectActionPerformed(evt);
  68. }
  69. });
  70. javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
  71. jPanel1.setLayout(jPanel1Layout);
  72. jPanel1Layout.setHorizontalGroup(
  73. jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  74. .addGroup(jPanel1Layout.createSequentialGroup()
  75. .addContainerGap(65, Short.MAX_VALUE)
  76. .addComponent(BtnConnect)
  77. .addContainerGap(76, Short.MAX_VALUE))
  78. );
  79. jPanel1Layout.setVerticalGroup(
  80. jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  81. .addGroup(jPanel1Layout.createSequentialGroup()
  82. .addContainerGap()
  83. .addComponent(BtnConnect)
  84. .addContainerGap(57, Short.MAX_VALUE))
  85. );
  86. dialogChooseMode.getContentPane().add(jPanel1);
  87. setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
  88. setMinimumSize(new java.awt.Dimension(568, 548));
  89. addWindowListener(new java.awt.event.WindowAdapter()
  90. {
  91. public void windowOpened(java.awt.event.WindowEvent evt)
  92. {
  93. formWindowOpened(evt);
  94. }
  95. });
  96. tfNachricht.setToolTipText("");
  97. tfNachricht.addMouseListener(new java.awt.event.MouseAdapter()
  98. {
  99. public void mouseClicked(java.awt.event.MouseEvent evt)
  100. {
  101. tfNachrichtMouseClicked(evt);
  102. }
  103. });
  104. tfNachricht.addActionListener(new java.awt.event.ActionListener()
  105. {
  106. public void actionPerformed(java.awt.event.ActionEvent evt)
  107. {
  108. tfNachrichtActionPerformed(evt);
  109. }
  110. });
  111. getContentPane().add(tfNachricht, java.awt.BorderLayout.PAGE_END);
  112. jScrollPane2.setPreferredSize(new java.awt.Dimension(238, 150));
  113. txtChat.setColumns(20);
  114. txtChat.setRows(5);
  115. txtChat.setText("Chat:");
  116. jScrollPane2.setViewportView(txtChat);
  117. getContentPane().add(jScrollPane2, java.awt.BorderLayout.CENTER);
  118. pack();
  119. }// </editor-fold>//GEN-END:initComponents
  120. private void BtnClientActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_BtnClientActionPerformed
  121. {//GEN-HEADEREND:event_BtnClientActionPerformed
  122. // TODO add your handling code here:
  123. }//GEN-LAST:event_BtnClientActionPerformed
  124. private void BtnServerActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_BtnServerActionPerformed
  125. {//GEN-HEADEREND:event_BtnServerActionPerformed
  126. // TODO add your handling code here:
  127. }//GEN-LAST:event_BtnServerActionPerformed
  128. private void tfNachrichtActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_tfNachrichtActionPerformed
  129. {//GEN-HEADEREND:event_tfNachrichtActionPerformed
  130. // TODO add your handling code here:
  131. }//GEN-LAST:event_tfNachrichtActionPerformed
  132. private void formWindowOpened(java.awt.event.WindowEvent evt)//GEN-FIRST:event_formWindowOpened
  133. {//GEN-HEADEREND:event_formWindowOpened
  134. dialogChooseMode.show();
  135. }//GEN-LAST:event_formWindowOpened
  136. private void tfNachrichtMouseClicked(java.awt.event.MouseEvent evt)//GEN-FIRST:event_tfNachrichtMouseClicked
  137. {//GEN-HEADEREND:event_tfNachrichtMouseClicked
  138. }//GEN-LAST:event_tfNachrichtMouseClicked
  139. private void BtnConnectActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_BtnConnectActionPerformed
  140. {//GEN-HEADEREND:event_BtnConnectActionPerformed
  141. // TODO add your handling code here:
  142. }//GEN-LAST:event_BtnConnectActionPerformed
  143. /**
  144. * @param args the command line arguments
  145. */
  146. public static void main(String args[])
  147. {
  148. /* Set the Nimbus look and feel */
  149. //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
  150. /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
  151. * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
  152. */
  153. try
  154. {
  155. for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels())
  156. {
  157. if ("Nimbus".equals(info.getName()))
  158. {
  159. javax.swing.UIManager.setLookAndFeel(info.getClassName());
  160. break;
  161. }
  162. }
  163. }
  164. catch (ClassNotFoundException ex)
  165. {
  166. java.util.logging.Logger.getLogger(ChatView.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  167. }
  168. catch (InstantiationException ex)
  169. {
  170. java.util.logging.Logger.getLogger(ChatView.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  171. }
  172. catch (IllegalAccessException ex)
  173. {
  174. java.util.logging.Logger.getLogger(ChatView.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  175. }
  176. catch (javax.swing.UnsupportedLookAndFeelException ex)
  177. {
  178. java.util.logging.Logger.getLogger(ChatView.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  179. }
  180. //</editor-fold>
  181. /* Create and display the form */
  182. java.awt.EventQueue.invokeLater(new Runnable()
  183. {
  184. public void run()
  185. {
  186. new ChatView().setVisible(true);
  187. }
  188. });
  189. }
  190. // Variables declaration - do not modify//GEN-BEGIN:variables
  191. private javax.swing.JRadioButton BtnClient;
  192. private javax.swing.JButton BtnConnect;
  193. private javax.swing.ButtonGroup BtnGrpMode;
  194. private javax.swing.JRadioButton BtnServer;
  195. private javax.swing.JDialog dialogChooseMode;
  196. private javax.swing.JPanel jPanel1;
  197. private javax.swing.JScrollPane jScrollPane2;
  198. private javax.swing.JLabel lblMode;
  199. private javax.swing.JTextField tfNachricht;
  200. private javax.swing.JTextArea txtChat;
  201. // End of variables declaration//GEN-END:variables
  202. /**
  203. * @return the BtnClient
  204. */
  205. public javax.swing.JRadioButton getBtnClient()
  206. {
  207. return BtnClient;
  208. }
  209. /**
  210. * @return the BtnConnect
  211. */
  212. public javax.swing.JButton getBtnConnect()
  213. {
  214. return BtnConnect;
  215. }
  216. /**
  217. * @return the BtnGrpMode
  218. */
  219. public javax.swing.ButtonGroup getBtnGrpMode()
  220. {
  221. return BtnGrpMode;
  222. }
  223. /**
  224. * @return the BtnServer
  225. */
  226. public javax.swing.JRadioButton getBtnServer()
  227. {
  228. return BtnServer;
  229. }
  230. /**
  231. * @return the jDialog1
  232. */
  233. public javax.swing.JDialog getjDialog1()
  234. {
  235. return dialogChooseMode;
  236. }
  237. /**
  238. * @return the tfNachricht
  239. */
  240. public javax.swing.JTextField getTfNachricht()
  241. {
  242. return tfNachricht;
  243. }
  244. /**
  245. * @return the txtChat
  246. */
  247. public javax.swing.JTextArea getTxtChat()
  248. {
  249. return txtChat;
  250. }
  251. }