001    /*
002     * CurrentBotStatePanel.java
003     *
004     * Created on February 24, 2002, 1:19 AM
005     */
006    
007    package edu.tamu.gamebots.ui;
008    
009    import edu.isi.gamebots.client.*;
010    
011    /**
012     * <p>
013     * A panel for displaying updates of the bots current state.
014     * Currently it displays:
015     * <ul>
016     * <li>Health</li>
017     * <li>Armor</li>
018     * <li>Location</li>
019     * <li>Weapon</li>
020     * <li>Ammo</li>
021     * <li>Rotation</li>
022     * </ul>
023     * </p>
024     * @author rtr7684
025     */
026    public class CurrentBotStatePanel extends javax.swing.JPanel {
027    
028      /** Creates new form CurrentBotStatePanel */
029        public CurrentBotStatePanel() {
030            initComponents();
031        }
032        
033        /**
034         * <p>
035         * Updates the display based on a new SLF message.
036         * </p>
037         * @param selfMessage The SLF message from the UT Gamebots server
038         */    
039        public void update(Message selfMessage){
040          healthField.setText(selfMessage.getProperty("Health"));
041          armorField.setText(selfMessage.getProperty("Armor"));
042          locationField.setText(selfMessage.getProperty("Location"));
043          weaponField.setText(selfMessage.getProperty("Weapon"));
044          ammoField.setText(selfMessage.getProperty("CurrentAmmo"));
045          rotationField.setText(selfMessage.getProperty("Rotation"));
046          velocityField.setText(selfMessage.getProperty("Velocity"));
047          revalidate();
048        }
049    
050        /** This method is called from within the constructor to
051         * initialize the form.
052         * WARNING: Do NOT modify this code. The content of this method is
053         * always regenerated by the Form Editor.
054         */
055      private void initComponents() {//GEN-BEGIN:initComponents
056        jPanel1 = new javax.swing.JPanel();
057        helathLabel = new javax.swing.JLabel();
058        healthField = new javax.swing.JTextField();
059        armorLabel = new javax.swing.JLabel();
060        armorField = new javax.swing.JTextField();
061        weaponLabel = new javax.swing.JLabel();
062        weaponField = new javax.swing.JTextField();
063        ammoLabel = new javax.swing.JLabel();
064        ammoField = new javax.swing.JTextField();
065        jPanel2 = new javax.swing.JPanel();
066        locationLabel = new javax.swing.JLabel();
067        locationField = new javax.swing.JTextField();
068        rotationLabel = new javax.swing.JLabel();
069        rotationField = new javax.swing.JTextField();
070        velocityLabel = new javax.swing.JLabel();
071        velocityField = new javax.swing.JTextField();
072    
073        setLayout(new javax.swing.BoxLayout(this, javax.swing.BoxLayout.Y_AXIS));
074    
075        jPanel1.setLayout(new javax.swing.BoxLayout(jPanel1, javax.swing.BoxLayout.X_AXIS));
076    
077        helathLabel.setText("Health: ");
078        jPanel1.add(helathLabel);
079    
080        healthField.setEditable(false);
081        healthField.setBorder(null);
082        jPanel1.add(healthField);
083    
084        armorLabel.setText("Armor: ");
085        jPanel1.add(armorLabel);
086    
087        armorField.setEditable(false);
088        armorField.setBorder(null);
089        jPanel1.add(armorField);
090    
091        weaponLabel.setText("Weapon: ");
092        jPanel1.add(weaponLabel);
093    
094        weaponField.setEditable(false);
095        weaponField.setBorder(null);
096        jPanel1.add(weaponField);
097    
098        ammoLabel.setText("Ammo: ");
099        jPanel1.add(ammoLabel);
100    
101        ammoField.setEditable(false);
102        ammoField.setBorder(null);
103        jPanel1.add(ammoField);
104    
105        add(jPanel1);
106    
107        jPanel2.setLayout(new javax.swing.BoxLayout(jPanel2, javax.swing.BoxLayout.X_AXIS));
108    
109        locationLabel.setText("Location: ");
110        jPanel2.add(locationLabel);
111    
112        locationField.setEditable(false);
113        locationField.setBorder(null);
114        locationField.addActionListener(new java.awt.event.ActionListener() {
115          public void actionPerformed(java.awt.event.ActionEvent evt) {
116            locationFieldActionPerformed(evt);
117          }
118        });
119    
120        jPanel2.add(locationField);
121    
122        rotationLabel.setText("Rotation: ");
123        jPanel2.add(rotationLabel);
124    
125        rotationField.setEditable(false);
126        rotationField.setBorder(null);
127        jPanel2.add(rotationField);
128    
129        velocityLabel.setText("Velocity: ");
130        jPanel2.add(velocityLabel);
131    
132        velocityField.setEditable(false);
133        velocityField.setBorder(null);
134        jPanel2.add(velocityField);
135    
136        add(jPanel2);
137    
138      }//GEN-END:initComponents
139    
140      private void locationFieldActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_locationFieldActionPerformed
141        // Add your handling code here:
142      }//GEN-LAST:event_locationFieldActionPerformed
143    
144    
145      // Variables declaration - do not modify//GEN-BEGIN:variables
146      private javax.swing.JLabel locationLabel;
147      private javax.swing.JTextField weaponField;
148      private javax.swing.JTextField healthField;
149      private javax.swing.JTextField armorField;
150      private javax.swing.JPanel jPanel2;
151      private javax.swing.JLabel weaponLabel;
152      private javax.swing.JPanel jPanel1;
153      private javax.swing.JLabel armorLabel;
154      private javax.swing.JLabel helathLabel;
155      private javax.swing.JTextField velocityField;
156      private javax.swing.JTextField rotationField;
157      private javax.swing.JLabel velocityLabel;
158      private javax.swing.JLabel rotationLabel;
159      private javax.swing.JTextField ammoField;
160      private javax.swing.JLabel ammoLabel;
161      private javax.swing.JTextField locationField;
162      // End of variables declaration//GEN-END:variables
163    
164    }