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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  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 grafikchat.view;
  7. /**
  8. *
  9. * @author marian
  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 lbIP
  32. */
  33. public javax.swing.JLabel getLbIP() {
  34. return lbIP;
  35. }
  36. /**
  37. * @return the lbPort
  38. */
  39. public javax.swing.JLabel getLbPort() {
  40. return lbPort;
  41. }
  42. /**
  43. * @return the tfIP
  44. */
  45. public javax.swing.JTextField getTfIP() {
  46. return tfIP;
  47. }
  48. /**
  49. * @return the tfPort
  50. */
  51. public javax.swing.JTextField getTfPort() {
  52. return tfPort;
  53. }
  54. /**
  55. * Creates new form ChatView
  56. */
  57. public ChatView() {
  58. initComponents();
  59. }
  60. /**
  61. * This method is called from within the constructor to initialize the form.
  62. * WARNING: Do NOT modify this code. The content of this method is always
  63. * regenerated by the Form Editor.
  64. */
  65. @SuppressWarnings("unchecked")
  66. // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
  67. private void initComponents() {
  68. bgSelect = new javax.swing.ButtonGroup();
  69. tfPort = new javax.swing.JTextField();
  70. lbPort = new javax.swing.JLabel();
  71. lbIP = new javax.swing.JLabel();
  72. tfIP = new javax.swing.JTextField();
  73. btConnect = new javax.swing.JButton();
  74. jSeparator1 = new javax.swing.JSeparator();
  75. rbClient = new javax.swing.JRadioButton();
  76. rbServer = new javax.swing.JRadioButton();
  77. gvDrawPane = new grafikchat.view.GrafikView();
  78. setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
  79. tfPort.setText("3210");
  80. tfPort.setToolTipText("");
  81. lbPort.setText("Port:");
  82. lbPort.setToolTipText("");
  83. lbIP.setText("IP:");
  84. tfIP.setText("127.0.0.1");
  85. btConnect.setText("connect");
  86. btConnect.setToolTipText("");
  87. bgSelect.add(rbClient);
  88. rbClient.setSelected(true);
  89. rbClient.setText("Client");
  90. bgSelect.add(rbServer);
  91. rbServer.setText("Server");
  92. javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
  93. getContentPane().setLayout(layout);
  94. layout.setHorizontalGroup(
  95. layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  96. .addGroup(layout.createSequentialGroup()
  97. .addContainerGap()
  98. .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  99. .addComponent(gvDrawPane, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
  100. .addGroup(layout.createSequentialGroup()
  101. .addComponent(rbClient, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
  102. .addGap(215, 215, 215))
  103. .addComponent(jSeparator1)
  104. .addGroup(layout.createSequentialGroup()
  105. .addComponent(lbPort)
  106. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  107. .addComponent(tfPort, javax.swing.GroupLayout.PREFERRED_SIZE, 61, javax.swing.GroupLayout.PREFERRED_SIZE)
  108. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  109. .addComponent(lbIP)
  110. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  111. .addComponent(tfIP, javax.swing.GroupLayout.DEFAULT_SIZE, 164, Short.MAX_VALUE)
  112. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  113. .addComponent(btConnect))
  114. .addGroup(layout.createSequentialGroup()
  115. .addComponent(rbServer)
  116. .addGap(0, 0, Short.MAX_VALUE)))
  117. .addContainerGap())
  118. );
  119. layout.setVerticalGroup(
  120. layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  121. .addGroup(layout.createSequentialGroup()
  122. .addContainerGap()
  123. .addComponent(rbClient)
  124. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  125. .addComponent(rbServer)
  126. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
  127. .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
  128. .addComponent(lbPort)
  129. .addComponent(tfPort, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
  130. .addComponent(tfIP, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
  131. .addComponent(lbIP)
  132. .addComponent(btConnect))
  133. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  134. .addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE)
  135. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  136. .addComponent(gvDrawPane, javax.swing.GroupLayout.DEFAULT_SIZE, 205, Short.MAX_VALUE)
  137. .addContainerGap())
  138. );
  139. pack();
  140. }// </editor-fold>//GEN-END:initComponents
  141. /**
  142. * @param args the command line arguments
  143. */
  144. public static void main(String args[]) {
  145. /* Set the Nimbus look and feel */
  146. //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
  147. /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
  148. * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
  149. */
  150. try {
  151. for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
  152. if ("Nimbus".equals(info.getName())) {
  153. javax.swing.UIManager.setLookAndFeel(info.getClassName());
  154. break;
  155. }
  156. }
  157. } catch (ClassNotFoundException ex) {
  158. java.util.logging.Logger.getLogger(ChatView.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  159. } catch (InstantiationException ex) {
  160. java.util.logging.Logger.getLogger(ChatView.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  161. } catch (IllegalAccessException ex) {
  162. java.util.logging.Logger.getLogger(ChatView.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  163. } catch (javax.swing.UnsupportedLookAndFeelException ex) {
  164. java.util.logging.Logger.getLogger(ChatView.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  165. }
  166. //</editor-fold>
  167. /* Create and display the form */
  168. java.awt.EventQueue.invokeLater(new Runnable() {
  169. public void run() {
  170. new ChatView().setVisible(true);
  171. }
  172. });
  173. }
  174. // Variables declaration - do not modify//GEN-BEGIN:variables
  175. private javax.swing.ButtonGroup bgSelect;
  176. private javax.swing.JButton btConnect;
  177. private grafikchat.view.GrafikView gvDrawPane;
  178. private javax.swing.JSeparator jSeparator1;
  179. private javax.swing.JLabel lbIP;
  180. private javax.swing.JLabel lbPort;
  181. private javax.swing.JRadioButton rbClient;
  182. private javax.swing.JRadioButton rbServer;
  183. private javax.swing.JTextField tfIP;
  184. private javax.swing.JTextField tfPort;
  185. // End of variables declaration//GEN-END:variables
  186. /**
  187. * @return the gvDrawPane
  188. */
  189. public grafikchat.view.GrafikView getGvDrawPane() {
  190. return gvDrawPane;
  191. }
  192. }