Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- package forme;
- import java.awt.HeadlessException;
- import komunikacija.KomunikacijaSaServerom;
- import konstante.Operacija;
- import logika.Kontroler;
- import nit.CekajOdgovorServeraUvijek;
- import transfer.KlijentskiZahtjev;
- /**
- *
- * @author tijan
- */
- public class GlavnaKlijentskaForma extends javax.swing.JFrame {
- /**
- * Creates new form GlavnaKlijentskaForma
- *
- *
- */
- public GlavnaKlijentskaForma() {
- initComponents();
- setVisible(true);
- Kontroler.getInstanca().setGkf(this);
- CekajOdgovorServeraUvijek cekaj = new CekajOdgovorServeraUvijek();
- cekaj.start();
- }
- /**
- * This method is called from within the constructor to initialize the form.
- * WARNING: Do NOT modify this code. The content of this method is always
- * regenerated by the Form Editor.
- */
- @SuppressWarnings("unchecked")
- // <editor-fold defaultstate="collapsed" desc="Generated Code">
- private void initComponents() {
- jLabel1 = new javax.swing.JLabel();
- jLabel2 = new javax.swing.JLabel();
- txtIme = new javax.swing.JTextField();
- txtPravoIme = new javax.swing.JTextField();
- btnUnesi = new javax.swing.JButton();
- jLabel3 = new javax.swing.JLabel();
- txtPretraga = new javax.swing.JTextField();
- btnVratiJednog = new javax.swing.JButton();
- jScrollPane1 = new javax.swing.JScrollPane();
- txtAreaSv = new javax.swing.JTextArea();
- btnVratiSve = new javax.swing.JButton();
- setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
- jLabel1.setText("Ime");
- jLabel2.setText("Pravo ime");
- txtPravoIme.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- txtPravoImeActionPerformed(evt);
- }
- });
- btnUnesi.setText("unesi");
- btnUnesi.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- btnUnesiActionPerformed(evt);
- }
- });
- jLabel3.setText("Vrati po imenu");
- btnVratiJednog.setText("vrati jednog");
- btnVratiJednog.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- btnVratiJednogActionPerformed(evt);
- }
- });
- txtAreaSv.setColumns(20);
- txtAreaSv.setRows(5);
- jScrollPane1.setViewportView(txtAreaSv);
- btnVratiSve.setText("vrati sve");
- btnVratiSve.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- btnVratiSveActionPerformed(evt);
- }
- });
- javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
- getContentPane().setLayout(layout);
- layout.setHorizontalGroup(
- layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(layout.createSequentialGroup()
- .addContainerGap()
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
- .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 397, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addGroup(layout.createSequentialGroup()
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addComponent(jLabel1)
- .addComponent(jLabel2)
- .addComponent(jLabel3))
- .addGap(26, 26, 26)
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
- .addComponent(txtIme)
- .addComponent(txtPravoIme)
- .addComponent(txtPretraga, javax.swing.GroupLayout.DEFAULT_SIZE, 319, Short.MAX_VALUE))))
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
- .addComponent(btnUnesi, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
- .addComponent(btnVratiJednog, javax.swing.GroupLayout.DEFAULT_SIZE, 119, Short.MAX_VALUE)
- .addComponent(btnVratiSve, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
- .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
- );
- layout.setVerticalGroup(
- layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(layout.createSequentialGroup()
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
- .addGroup(layout.createSequentialGroup()
- .addContainerGap()
- .addComponent(btnUnesi, javax.swing.GroupLayout.PREFERRED_SIZE, 67, javax.swing.GroupLayout.PREFERRED_SIZE))
- .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
- .addGap(38, 38, 38)
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
- .addComponent(jLabel1)
- .addComponent(txtIme, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
- .addGap(23, 23, 23)
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
- .addComponent(jLabel2)
- .addComponent(txtPravoIme, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))))
- .addGap(25, 25, 25)
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
- .addComponent(jLabel3)
- .addComponent(txtPretraga, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addComponent(btnVratiJednog))
- .addGap(18, 18, 18)
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addComponent(btnVratiSve))
- .addContainerGap(37, Short.MAX_VALUE))
- );
- pack();
- }// </editor-fold>
- private void txtPravoImeActionPerformed(java.awt.event.ActionEvent evt) {
- // TODO add your handling code here:
- }
- private void btnUnesiActionPerformed(java.awt.event.ActionEvent evt) {
- String ime = txtIme.getText();
- String pravoIme = txtPravoIme.getText();
- KlijentskiZahtjev kz = new KlijentskiZahtjev();
- kz.setOperacija(Operacija.UNESI_JUNAKA);
- String[] podaci = {ime, pravoIme};
- kz.setParametar(podaci);
- KomunikacijaSaServerom.getKom().posaljiZahtjev(kz);
- }
- private void btnVratiJednogActionPerformed(java.awt.event.ActionEvent evt) {
- String ime = txtPretraga.getText();
- KlijentskiZahtjev kz = new KlijentskiZahtjev();
- kz.setOperacija(Operacija.VRATI_JUNAKA);
- kz.setParametar(ime);
- KomunikacijaSaServerom.getKom().posaljiZahtjev(kz);
- }
- private void btnVratiSveActionPerformed(java.awt.event.ActionEvent evt) {
- KlijentskiZahtjev kz = new KlijentskiZahtjev();
- kz.setOperacija(Operacija.VRATI_SVE);
- KomunikacijaSaServerom.getKom().posaljiZahtjev(kz);
- }
- /**
- * @param args the command line arguments
- */
- public static void main(String args[]) {
- /* Set the Nimbus look and feel */
- //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
- /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
- * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
- */
- try {
- for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
- if ("Nimbus".equals(info.getName())) {
- javax.swing.UIManager.setLookAndFeel(info.getClassName());
- break;
- }
- }
- } catch (ClassNotFoundException ex) {
- java.util.logging.Logger.getLogger(GlavnaKlijentskaForma.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
- } catch (InstantiationException ex) {
- java.util.logging.Logger.getLogger(GlavnaKlijentskaForma.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
- } catch (IllegalAccessException ex) {
- java.util.logging.Logger.getLogger(GlavnaKlijentskaForma.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
- } catch (javax.swing.UnsupportedLookAndFeelException ex) {
- java.util.logging.Logger.getLogger(GlavnaKlijentskaForma.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
- }
- //</editor-fold>
- /* Create and display the form */
- java.awt.EventQueue.invokeLater(new Runnable() {
- public void run() {
- new GlavnaKlijentskaForma().setVisible(true);
- }
- });
- }
- // Variables declaration - do not modify
- private javax.swing.JButton btnUnesi;
- private javax.swing.JButton btnVratiJednog;
- private javax.swing.JButton btnVratiSve;
- private javax.swing.JLabel jLabel1;
- private javax.swing.JLabel jLabel2;
- private javax.swing.JLabel jLabel3;
- private javax.swing.JScrollPane jScrollPane1;
- private javax.swing.JTextArea txtAreaSv;
- private javax.swing.JTextField txtIme;
- private javax.swing.JTextField txtPravoIme;
- private javax.swing.JTextField txtPretraga;
- // End of variables declaration
- public void popuniOnoSranje(String poruka) {
- txtAreaSv.setText(poruka);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement