Biblioteca Java - Blame information for rev 3

Subversion Repositories:
Rev:
Rev Author Line No. Line
3 mihai 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 designpatterns.mvc.gara;
7  
8 import java.awt.Dimension;
9 import java.util.Observable;
10 import java.util.Observer;
11  
12 /**
13  *
14  * @author evo2
15  */
16 public class GaraView extends javax.swing.JFrame implements Observer{
17  
18     GaraControler controler;
19     /**
20      * Creates new form GaraView
21      */
22     public GaraView(GaraControler controler) {
23         this.controler = controler;
24         initComponents();
25         this.setSize(new Dimension(500,400));
26     }
27  
28     /**
29      * This method is called from within the constructor to initialize the form.
30      * WARNING: Do NOT modify this code. The content of this method is always
31      * regenerated by the Form Editor.
32      */
33     @SuppressWarnings("unchecked")
34     // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
35     private void initComponents() {
36  
37         jLabel2 = new javax.swing.JLabel();
38         jtLinia1 = new javax.swing.JTextField();
39         jScrollPane1 = new javax.swing.JScrollPane();
40         jtArea = new javax.swing.JTextArea();
41         jbSchimbaSemafor = new javax.swing.JButton();
42  
43         setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
44         getContentPane().setLayout(null);
45  
46         jLabel2.setText("Linia 1");
47         getContentPane().add(jLabel2);
48         jLabel2.setBounds(30, 70, 50, 14);
49         getContentPane().add(jtLinia1);
50         jtLinia1.setBounds(80, 70, 100, 20);
51  
52         jtArea.setColumns(20);
53         jtArea.setRows(5);
54         jScrollPane1.setViewportView(jtArea);
55  
56         getContentPane().add(jScrollPane1);
57         jScrollPane1.setBounds(20, 130, 370, 160);
58  
59         jbSchimbaSemafor.setText("Schimba semafor");
60         jbSchimbaSemafor.addActionListener(new java.awt.event.ActionListener() {
61             public void actionPerformed(java.awt.event.ActionEvent evt) {
62                 jbSchimbaSemaforActionPerformed(evt);
63             }
64         });
65         getContentPane().add(jbSchimbaSemafor);
66         jbSchimbaSemafor.setBounds(260, 70, 120, 23);
67  
68         pack();
69     }// </editor-fold>//GEN-END:initComponents
70  
71     private void jbSchimbaSemaforActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbSchimbaSemaforActionPerformed
72         controler.schimbaSemafor();
73     }//GEN-LAST:event_jbSchimbaSemaforActionPerformed
74  
75     /**
76      * @param args the command line arguments
77      */
78     public static void main(String args[]) {
79         /* Set the Nimbus look and feel */
80         //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
81         /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
82          * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
83          */
84         try {
85             for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
86                 if ("Nimbus".equals(info.getName())) {
87                     javax.swing.UIManager.setLookAndFeel(info.getClassName());
88                     break;
89                 }
90             }
91         } catch (ClassNotFoundException ex) {
92             java.util.logging.Logger.getLogger(GaraView.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
93         } catch (InstantiationException ex) {
94             java.util.logging.Logger.getLogger(GaraView.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
95         } catch (IllegalAccessException ex) {
96             java.util.logging.Logger.getLogger(GaraView.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
97         } catch (javax.swing.UnsupportedLookAndFeelException ex) {
98             java.util.logging.Logger.getLogger(GaraView.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
99         }
100         //</editor-fold>
101         //</editor-fold>
102  
103         /* Create and display the form */
104         java.awt.EventQueue.invokeLater(new Runnable() {
105             public void run() {
106                 new GaraView(null).setVisible(true);
107             }
108         });
109     }
110  
111     // Variables declaration - do not modify//GEN-BEGIN:variables
112     private javax.swing.JLabel jLabel2;
113     private javax.swing.JScrollPane jScrollPane1;
114     private javax.swing.JButton jbSchimbaSemafor;
115     private javax.swing.JTextArea jtArea;
116     private javax.swing.JTextField jtLinia1;
117     // End of variables declaration//GEN-END:variables
118  
119     @Override
120     public void update(Observable o, Object arg) {
121  
122             Gara gara = (Gara)o;
123  
124             if(arg.equals(Gara.EVENIMENT_SOSESTE_TREN)){
125                 jtLinia1.setText(gara.getLinia1());
126                 jtArea.append("Trenul "+gara.getLinia1()+" a sosit in gara!\n");
127             }
128  
129             if(arg.equals(Gara.EVENIMENT_SEMAFOR_SCHIMBAT)){            
130                 jtArea.append("Semafor schimbat:"+gara.getSemafor()+" \n");
131             }
132  
133     }
134 }