/*
* WindViewer.java
*
* Created on 22 juin 2006, 11:34
*/
package test.view;
import java.util.*;
import test.control.WindControllable;
import test.model.Wind;
/**
*
* @author André
*/
public class WindViewer extends javax.swing.JFrame implements Observer{
/** Creates new form WindViewer */
public WindViewer(WindControllable controller ) {
this.controller = controller;
initComponents();
setVisible(true);
}
/** 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.
*/
// <editor-fold defaultstate="collapsed" desc=" Generated Code ">
private void initComponents() {
mainPanel = new javax.swing.JPanel();
direction = new javax.swing.JLabel();
speed = new javax.swing.JLabel();
buttonPanel = new javax.swing.JPanel();
btDirection = new javax.swing.JButton();
btSpeed = new javax.swing.JButton();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
mainPanel.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
direction.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
direction.setPreferredSize(new java.awt.Dimension(100, 25));
mainPanel.add(direction);
speed.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
speed.setPreferredSize(new java.awt.Dimension(100, 25));
mainPanel.add(speed);
getContentPane().add(mainPanel, java.awt.BorderLayout.CENTER);
btDirection.setText("Change direction");
btDirection.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btDirectionActionPerformed(evt);
}
});
buttonPanel.add(btDirection);
btSpeed.setText("Change Speed");
btSpeed.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btSpeedActionPerformed(evt);
}
});
buttonPanel.add(btSpeed);
getContentPane().add(buttonPanel, java.awt.BorderLayout.SOUTH);
java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
setBounds((screenSize.width-274)/2, (screenSize.height-117)/2, 274, 117);
}// </editor-fold>
private void btDirectionActionPerformed(java.awt.event.ActionEvent evt) {
controller.changeDirection();
}
private void btSpeedActionPerformed(java.awt.event.ActionEvent evt) {
controller.changeSpeed();
}
public void update(Observable o, Object arg) {
Wind wind = ( Wind ) arg;
direction.setText( wind.getDir().toString() );
speed.setText( String.valueOf( wind.getSpeed() ) );
}
private WindControllable controller;
// Variables declaration - do not modify
private javax.swing.JButton btDirection;
private javax.swing.JButton btSpeed;
private javax.swing.JPanel buttonPanel;
private javax.swing.JLabel direction;
private javax.swing.JPanel mainPanel;
private javax.swing.JLabel speed;
// End of variables declaration
}