Biblioteca Java - Blame information for rev 32

Subversion Repositories:
Rev:
Rev Author Line No. Line
32 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 elevatorcurs.ui;
7  
8 import elevatorcurs.model.Elevator;
9 import java.util.Observable;
10 import java.util.Observer;
11  
12 /**
13  *
14  * @author Mihai Hulea mihai.hulea@aut.utcluj.ro
15  */
16 public class ElevatorUI extends javax.swing.JFrame implements Observer{
17  
18     ElevatorMVCController ctrl;
19     /**
20      * Creates new form ElevatorUI
21      */
22     public ElevatorUI() {
23         initComponents();
24     }
25  
26     public void initControler(ElevatorMVCController c){
27         this.ctrl = c;
28     }
29  
30     /**
31      * This method is called from within the constructor to initialize the form.
32      * WARNING: Do NOT modify this code. The content of this method is always
33      * regenerated by the Form Editor.
34      */
35     @SuppressWarnings("unchecked")
36     // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
37     private void initComponents() {
38  
39         jButton1 = new javax.swing.JButton();
40         jButton2 = new javax.swing.JButton();
41         jButton3 = new javax.swing.JButton();
42         jButton4 = new javax.swing.JButton();
43         jScrollPane1 = new javax.swing.JScrollPane();
44         jTextArea1 = new javax.swing.JTextArea();
45  
46         setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
47  
48         jButton1.setText("Floor 3");
49         jButton1.addActionListener(new java.awt.event.ActionListener() {
50             public void actionPerformed(java.awt.event.ActionEvent evt) {
51                 jButton1ActionPerformed(evt);
52             }
53         });
54  
55         jButton2.setText("Floor 2");
56         jButton2.addActionListener(new java.awt.event.ActionListener() {
57             public void actionPerformed(java.awt.event.ActionEvent evt) {
58                 jButton2ActionPerformed(evt);
59             }
60         });
61  
62         jButton3.setText("Floor 1");
63         jButton3.addActionListener(new java.awt.event.ActionListener() {
64             public void actionPerformed(java.awt.event.ActionEvent evt) {
65                 jButton3ActionPerformed(evt);
66             }
67         });
68  
69         jButton4.setText("Floor 0");
70         jButton4.addActionListener(new java.awt.event.ActionListener() {
71             public void actionPerformed(java.awt.event.ActionEvent evt) {
72                 jButton4ActionPerformed(evt);
73             }
74         });
75  
76         jTextArea1.setColumns(20);
77         jTextArea1.setRows(5);
78         jScrollPane1.setViewportView(jTextArea1);
79  
80         javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
81         getContentPane().setLayout(layout);
82         layout.setHorizontalGroup(
83             layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
84             .addGroup(layout.createSequentialGroup()
85                 .addContainerGap()
86                 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
87                     .addComponent(jButton4)
88                     .addComponent(jButton1)
89                     .addComponent(jButton2)
90                     .addComponent(jButton3))
91                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
92                 .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 309, Short.MAX_VALUE)
93                 .addContainerGap())
94         );
95         layout.setVerticalGroup(
96             layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
97             .addGroup(layout.createSequentialGroup()
98                 .addContainerGap()
99                 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
100                     .addComponent(jScrollPane1)
101                     .addGroup(layout.createSequentialGroup()
102                         .addComponent(jButton1)
103                         .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
104                         .addComponent(jButton2)
105                         .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
106                         .addComponent(jButton3)
107                         .addGap(15, 15, 15)
108                         .addComponent(jButton4)
109                         .addGap(0, 0, Short.MAX_VALUE)))
110                 .addContainerGap())
111         );
112  
113         pack();
114     }// </editor-fold>//GEN-END:initComponents
115  
116     private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton4ActionPerformed
117         ctrl.executeFloorCommand(0);
118     }//GEN-LAST:event_jButton4ActionPerformed
119  
120     private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed
121         ctrl.executeFloorCommand(1);
122     }//GEN-LAST:event_jButton3ActionPerformed
123  
124     private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
125         ctrl.executeFloorCommand(2);
126     }//GEN-LAST:event_jButton2ActionPerformed
127  
128     private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
129         ctrl.executeFloorCommand(3);
130     }//GEN-LAST:event_jButton1ActionPerformed
131  
132     /**
133      * @param args the command line arguments
134      */
135     public static void main(String args[]) {
136         /* Set the Nimbus look and feel */
137         //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
138         /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
139          * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
140          */
141         try {
142             for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
143                 if ("Nimbus".equals(info.getName())) {
144                     javax.swing.UIManager.setLookAndFeel(info.getClassName());
145                     break;
146                 }
147             }
148         } catch (ClassNotFoundException ex) {
149             java.util.logging.Logger.getLogger(ElevatorUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
150         } catch (InstantiationException ex) {
151             java.util.logging.Logger.getLogger(ElevatorUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
152         } catch (IllegalAccessException ex) {
153             java.util.logging.Logger.getLogger(ElevatorUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
154         } catch (javax.swing.UnsupportedLookAndFeelException ex) {
155             java.util.logging.Logger.getLogger(ElevatorUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
156         }
157         //</editor-fold>
158  
159         /* Create and display the form */
160         java.awt.EventQueue.invokeLater(new Runnable() {
161             public void run() {
162                 new ElevatorUI().setVisible(true);
163             }
164         });
165     }
166  
167     // Variables declaration - do not modify//GEN-BEGIN:variables
168     private javax.swing.JButton jButton1;
169     private javax.swing.JButton jButton2;
170     private javax.swing.JButton jButton3;
171     private javax.swing.JButton jButton4;
172     private javax.swing.JScrollPane jScrollPane1;
173     private javax.swing.JTextArea jTextArea1;
174     // End of variables declaration//GEN-END:variables
175  
176     @Override
177     public void update(Observable o, Object arg) {
178         this.jTextArea1.insert(((Elevator)arg).toString()+"\n", 1);
179     }
180 }