Advertisement
Guest User

Untitled

a guest
Feb 24th, 2020
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 11.19 KB | None | 0 0
  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 forme;
  7.  
  8. import java.awt.HeadlessException;
  9. import komunikacija.KomunikacijaSaServerom;
  10. import konstante.Operacija;
  11. import logika.Kontroler;
  12. import nit.CekajOdgovorServeraUvijek;
  13. import transfer.KlijentskiZahtjev;
  14.  
  15.  
  16.  
  17.  
  18. /**
  19.  *
  20.  * @author tijan
  21.  */
  22. public class GlavnaKlijentskaForma extends javax.swing.JFrame {
  23.  
  24.     /**
  25.      * Creates new form GlavnaKlijentskaForma
  26.      *
  27.      *
  28.      */
  29.    
  30.    
  31.     public GlavnaKlijentskaForma() {
  32.         initComponents();
  33.         setVisible(true);
  34.         Kontroler.getInstanca().setGkf(this);
  35.         CekajOdgovorServeraUvijek cekaj = new CekajOdgovorServeraUvijek();
  36.         cekaj.start();
  37.     }
  38.  
  39.     /**
  40.      * This method is called from within the constructor to initialize the form.
  41.      * WARNING: Do NOT modify this code. The content of this method is always
  42.      * regenerated by the Form Editor.
  43.      */
  44.     @SuppressWarnings("unchecked")
  45.     // <editor-fold defaultstate="collapsed" desc="Generated Code">                          
  46.     private void initComponents() {
  47.  
  48.         jLabel1 = new javax.swing.JLabel();
  49.         jLabel2 = new javax.swing.JLabel();
  50.         txtIme = new javax.swing.JTextField();
  51.         txtPravoIme = new javax.swing.JTextField();
  52.         btnUnesi = new javax.swing.JButton();
  53.         jLabel3 = new javax.swing.JLabel();
  54.         txtPretraga = new javax.swing.JTextField();
  55.         btnVratiJednog = new javax.swing.JButton();
  56.         jScrollPane1 = new javax.swing.JScrollPane();
  57.         txtAreaSv = new javax.swing.JTextArea();
  58.         btnVratiSve = new javax.swing.JButton();
  59.  
  60.         setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
  61.  
  62.         jLabel1.setText("Ime");
  63.  
  64.         jLabel2.setText("Pravo ime");
  65.  
  66.         txtPravoIme.addActionListener(new java.awt.event.ActionListener() {
  67.             public void actionPerformed(java.awt.event.ActionEvent evt) {
  68.                 txtPravoImeActionPerformed(evt);
  69.             }
  70.         });
  71.  
  72.         btnUnesi.setText("unesi");
  73.         btnUnesi.addActionListener(new java.awt.event.ActionListener() {
  74.             public void actionPerformed(java.awt.event.ActionEvent evt) {
  75.                 btnUnesiActionPerformed(evt);
  76.             }
  77.         });
  78.  
  79.         jLabel3.setText("Vrati po imenu");
  80.  
  81.         btnVratiJednog.setText("vrati jednog");
  82.         btnVratiJednog.addActionListener(new java.awt.event.ActionListener() {
  83.             public void actionPerformed(java.awt.event.ActionEvent evt) {
  84.                 btnVratiJednogActionPerformed(evt);
  85.             }
  86.         });
  87.  
  88.         txtAreaSv.setColumns(20);
  89.         txtAreaSv.setRows(5);
  90.         jScrollPane1.setViewportView(txtAreaSv);
  91.  
  92.         btnVratiSve.setText("vrati sve");
  93.         btnVratiSve.addActionListener(new java.awt.event.ActionListener() {
  94.             public void actionPerformed(java.awt.event.ActionEvent evt) {
  95.                 btnVratiSveActionPerformed(evt);
  96.             }
  97.         });
  98.  
  99.         javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
  100.         getContentPane().setLayout(layout);
  101.         layout.setHorizontalGroup(
  102.             layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  103.             .addGroup(layout.createSequentialGroup()
  104.                 .addContainerGap()
  105.                 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
  106.                     .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 397, javax.swing.GroupLayout.PREFERRED_SIZE)
  107.                     .addGroup(layout.createSequentialGroup()
  108.                         .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  109.                             .addComponent(jLabel1)
  110.                             .addComponent(jLabel2)
  111.                             .addComponent(jLabel3))
  112.                         .addGap(26, 26, 26)
  113.                         .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
  114.                             .addComponent(txtIme)
  115.                             .addComponent(txtPravoIme)
  116.                             .addComponent(txtPretraga, javax.swing.GroupLayout.DEFAULT_SIZE, 319, Short.MAX_VALUE))))
  117.                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
  118.                 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
  119.                     .addComponent(btnUnesi, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
  120.                     .addComponent(btnVratiJednog, javax.swing.GroupLayout.DEFAULT_SIZE, 119, Short.MAX_VALUE)
  121.                     .addComponent(btnVratiSve, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
  122.                 .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
  123.         );
  124.         layout.setVerticalGroup(
  125.             layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  126.             .addGroup(layout.createSequentialGroup()
  127.                 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
  128.                     .addGroup(layout.createSequentialGroup()
  129.                         .addContainerGap()
  130.                         .addComponent(btnUnesi, javax.swing.GroupLayout.PREFERRED_SIZE, 67, javax.swing.GroupLayout.PREFERRED_SIZE))
  131.                     .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
  132.                         .addGap(38, 38, 38)
  133.                         .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
  134.                             .addComponent(jLabel1)
  135.                             .addComponent(txtIme, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
  136.                         .addGap(23, 23, 23)
  137.                         .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
  138.                             .addComponent(jLabel2)
  139.                             .addComponent(txtPravoIme, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))))
  140.                 .addGap(25, 25, 25)
  141.                 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
  142.                     .addComponent(jLabel3)
  143.                     .addComponent(txtPretraga, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
  144.                     .addComponent(btnVratiJednog))
  145.                 .addGap(18, 18, 18)
  146.                 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  147.                     .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
  148.                     .addComponent(btnVratiSve))
  149.                 .addContainerGap(37, Short.MAX_VALUE))
  150.         );
  151.  
  152.         pack();
  153.     }// </editor-fold>                        
  154.  
  155.     private void txtPravoImeActionPerformed(java.awt.event.ActionEvent evt) {                                            
  156.         // TODO add your handling code here:
  157.     }                                          
  158.  
  159.     private void btnUnesiActionPerformed(java.awt.event.ActionEvent evt) {                                        
  160.         String ime = txtIme.getText();
  161.         String pravoIme = txtPravoIme.getText();
  162.         KlijentskiZahtjev kz = new KlijentskiZahtjev();
  163.         kz.setOperacija(Operacija.UNESI_JUNAKA);
  164.         String[] podaci = {ime, pravoIme};
  165.         kz.setParametar(podaci);
  166.         KomunikacijaSaServerom.getKom().posaljiZahtjev(kz);
  167.        
  168.  
  169.     }                                        
  170.  
  171.     private void btnVratiJednogActionPerformed(java.awt.event.ActionEvent evt) {                                              
  172.         String ime = txtPretraga.getText();
  173.         KlijentskiZahtjev kz = new KlijentskiZahtjev();
  174.         kz.setOperacija(Operacija.VRATI_JUNAKA);
  175.         kz.setParametar(ime);
  176.         KomunikacijaSaServerom.getKom().posaljiZahtjev(kz);
  177.        
  178.  
  179.     }                                              
  180.  
  181.     private void btnVratiSveActionPerformed(java.awt.event.ActionEvent evt) {                                            
  182.         KlijentskiZahtjev kz = new KlijentskiZahtjev();
  183.         kz.setOperacija(Operacija.VRATI_SVE);
  184.         KomunikacijaSaServerom.getKom().posaljiZahtjev(kz);
  185.     }                                          
  186.  
  187.     /**
  188.      * @param args the command line arguments
  189.      */
  190.     public static void main(String args[]) {
  191.         /* Set the Nimbus look and feel */
  192.         //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
  193.         /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
  194.          * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
  195.          */
  196.         try {
  197.             for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
  198.                 if ("Nimbus".equals(info.getName())) {
  199.                     javax.swing.UIManager.setLookAndFeel(info.getClassName());
  200.                     break;
  201.                 }
  202.             }
  203.         } catch (ClassNotFoundException ex) {
  204.             java.util.logging.Logger.getLogger(GlavnaKlijentskaForma.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  205.         } catch (InstantiationException ex) {
  206.             java.util.logging.Logger.getLogger(GlavnaKlijentskaForma.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  207.         } catch (IllegalAccessException ex) {
  208.             java.util.logging.Logger.getLogger(GlavnaKlijentskaForma.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  209.         } catch (javax.swing.UnsupportedLookAndFeelException ex) {
  210.             java.util.logging.Logger.getLogger(GlavnaKlijentskaForma.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  211.         }
  212.         //</editor-fold>
  213.  
  214.         /* Create and display the form */
  215.         java.awt.EventQueue.invokeLater(new Runnable() {
  216.             public void run() {
  217.                 new GlavnaKlijentskaForma().setVisible(true);
  218.             }
  219.         });
  220.     }
  221.  
  222.     // Variables declaration - do not modify                    
  223.     private javax.swing.JButton btnUnesi;
  224.     private javax.swing.JButton btnVratiJednog;
  225.     private javax.swing.JButton btnVratiSve;
  226.     private javax.swing.JLabel jLabel1;
  227.     private javax.swing.JLabel jLabel2;
  228.     private javax.swing.JLabel jLabel3;
  229.     private javax.swing.JScrollPane jScrollPane1;
  230.     private javax.swing.JTextArea txtAreaSv;
  231.     private javax.swing.JTextField txtIme;
  232.     private javax.swing.JTextField txtPravoIme;
  233.     private javax.swing.JTextField txtPretraga;
  234.     // End of variables declaration                  
  235.  
  236.     public void popuniOnoSranje(String poruka) {
  237.        
  238.         txtAreaSv.setText(poruka);
  239.     }
  240. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement