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.9KB

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