Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: org/livingpaper/hansa/ProductionSliderListener.java


1   //
2   //  ProductionSliderListener.java
3   //  Hansa
4   //
5   //  Created by mikel evins on Mon Aug 19 2002.
6   //  Version: $Id: ProductionSliderListener.java,v 1.1 2003/04/07 06:26:25 mikel Exp $
7   //  Copyright (c) 2002 by mikel evins
8   //  
9   //
10  package org.livingpaper.hansa;
11  
12  import javax.swing.JSlider;
13  import javax.swing.event.ChangeListener;
14  import javax.swing.event.ChangeEvent;
15  
16  public class ProductionSliderListener implements ChangeListener {
17    private HansaWindow mMainWindow = null;
18    private int mGood = GameModel.kNoGood;
19  
20    public ProductionSliderListener(HansaWindow mainWindow, int good){
21      mMainWindow = mainWindow;
22      mGood = good;
23    }
24  
25    public HansaWindow getMainWindow(){
26      return mMainWindow;
27    }
28  
29    public void stateChanged(ChangeEvent e){
30      JSlider source = (JSlider)e.getSource();
31      // if the user is still dragging the slider around we don't
32      // adjust anything when the user stops frobbing the slider,
33      // then we adjust the production value
34      if (!source.getValueIsAdjusting()) {
35              int production = (int)source.getValue();
36        GameModel model = mMainWindow.getModel();
37        model.setProduction(mGood, production);
38      }
39    }
40  }