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.senzor;
7  
8 import java.util.Observable;
9 import java.util.Observer;
10  
11 /**
12  *
13  * @author evo2
14  */
15 public class SenzorView extends javax.swing.JFrame implements Observer{
16  
17     /**
18      * Creates new form SenzorView
19      */
20     public SenzorView() {
21  
22         initComponents();
23         this.setSize(500, 500);
24     }
25  
26     /**
27      * This method is called from within the constructor to initialize the form.
28      * WARNING: Do NOT modify this code. The content of this method is always
29      * regenerated by the Form Editor.
30      */
31     @SuppressWarnings("unchecked")
32     // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
33     private void initComponents() {
34  
35         textFieldSensor = new javax.swing.JTextField();
36  
37         setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
38  
39         javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
40         getContentPane().setLayout(layout);
41         layout.setHorizontalGroup(
42             layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
43             .addGroup(layout.createSequentialGroup()
44                 .addGap(37, 37, 37)
45                 .addComponent(textFieldSensor, javax.swing.GroupLayout.PREFERRED_SIZE, 201, javax.swing.GroupLayout.PREFERRED_SIZE)
46                 .addContainerGap(162, Short.MAX_VALUE))
47         );
48         layout.setVerticalGroup(
49             layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
50             .addGroup(layout.createSequentialGroup()
51                 .addGap(52, 52, 52)
52                 .addComponent(textFieldSensor, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
53                 .addContainerGap(228, Short.MAX_VALUE))
54         );
55  
56         pack();
57     }// </editor-fold>//GEN-END:initComponents
58  
59     /**
60      * @param args the command line arguments
61      */
62     public static void main(String args[]) {
63         /* Set the Nimbus look and feel */
64         //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
65         /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
66          * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
67          */
68         try {
69             for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
70                 if ("Nimbus".equals(info.getName())) {
71                     javax.swing.UIManager.setLookAndFeel(info.getClassName());
72                     break;
73                 }
74             }
75         } catch (ClassNotFoundException ex) {
76             java.util.logging.Logger.getLogger(SenzorView.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
77         } catch (InstantiationException ex) {
78             java.util.logging.Logger.getLogger(SenzorView.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
79         } catch (IllegalAccessException ex) {
80             java.util.logging.Logger.getLogger(SenzorView.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
81         } catch (javax.swing.UnsupportedLookAndFeelException ex) {
82             java.util.logging.Logger.getLogger(SenzorView.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
83         }
84         //</editor-fold>
85         //</editor-fold>
86  
87         /* Create and display the form */
88         java.awt.EventQueue.invokeLater(new Runnable() {
89             public void run() {
90                 new SenzorView().setVisible(true);
91             }
92         });
93     }
94  
95     // Variables declaration - do not modify//GEN-BEGIN:variables
96     private javax.swing.JTextField textFieldSensor;
97     // End of variables declaration//GEN-END:variables
98  
99     @Override
100     public void update(Observable o, Object arg) {
101         if(o instanceof Senzor){
102             Senzor s = (Senzor)o;
103             this.textFieldSensor.setText(""+s.getValoare());
104         }
105     }
106 }