home *** CD-ROM | disk | FTP | other *** search
/ io Programmo 14 / IOPROG_14.ISO / soft / sdkjava / sdkjava.exe / SDKJava.cab / AFC102 / Samples / Scrolls / Src / SpinnerPnl.java < prev   
Encoding:
Java Source  |  1998-03-05  |  1.4 KB  |  49 lines

  1. //
  2. // (c) 1997 Microsoft Corporation.  All rights reserved.
  3. //
  4. import java.awt.Insets;
  5. import java.awt.Image;
  6. import com.ms.ui.*;
  7.  
  8. public class SpinnerPnl extends UIPanel implements SDKConsts
  9. {
  10.     public UISpinner ctrl;
  11.  
  12.     private UIGraphic sunrise;
  13.     private Image frames[] = new Image[NUM_FRAMES+1];
  14.  
  15.     public SpinnerPnl()
  16.     {
  17.         setLayout(new UIBorderLayout());
  18.  
  19.         // load images for animation
  20.         for ( int i = 0; i < NUM_FRAMES; i++ )
  21.             frames[i] = SDKImages.get(SUNRISE+i);
  22.         frames[NUM_FRAMES] = frames[0];
  23.  
  24.         // Create UISpinner control
  25.         ctrl = new UISpinner(UISpinner.RAISED | UISpinner.VERTICAL | UISpinner.CIRCULAR,
  26.                                     0, MAX_SCROLL, 0, SPIN_INC, INIT_POS);
  27.  
  28.         // Create BUDDY associated w/ UISpinner
  29.         sunrise = new UIGraphic(frames[INIT_POS/SPIN_INC], UIStatic.RIGHT);
  30.  
  31.         // Create inset panel for buddy and add to spinner
  32.         SDKInsetPanelBL ipnl = new SDKInsetPanelBL(0,10,0,10);
  33.         ipnl.add(sunrise, "center"); ctrl.add(UISpinner.BUDDY, ipnl);
  34.  
  35.         // Create UIGroup for spinner
  36.         UIGroup group = new UIGroup("UISpinner"); group.setLayout(new UIBorderLayout());
  37.         ipnl = new SDKInsetPanelBL(13,10,13,22);
  38.         ipnl.add(ctrl, "center"); group.add(ipnl, "center"); add(group, "center");
  39.     }
  40.  
  41.     public void setImage(int pos)
  42.     {
  43.         sunrise.setImage(frames[pos/SPIN_INC]);
  44.         sunrise.setValid(true);
  45.     }
  46.  
  47.     public Insets getInsets() { return new Insets(0,0,0,0); }
  48. }
  49.