home *** CD-ROM | disk | FTP | other *** search
/ io Programmo 39 / IOPROG_39.ISO / SOFT / sdkjava40.exe / data1.cab / fg_Samples / Samples / ActiveX / JChart / JChartCustomizer.java < prev    next >
Encoding:
Java Source  |  2000-05-04  |  3.1 KB  |  92 lines

  1. ///////////////////////////////////////////////////////////////////////////
  2. //
  3. //  JChartCustomizer.java
  4. //
  5. //  This is the customizer for the JChart class. It provides editors for all the
  6. //  chart properties.
  7. //
  8. //  (C) Copyright 1995 - 1999 Microsoft Corporation.  All rights reserved.
  9. //
  10. ///////////////////////////////////////////////////////////////////////////
  11.  
  12. import java.beans.*;
  13. import java.awt.*;
  14. import java.awt.event.*;
  15. import com.ms.ui.*;
  16.  
  17. public class JChartCustomizer extends Panel implements Customizer
  18. {
  19.     private UITabViewer tabViewer;                  // The tab viewer which contains all the property editors
  20.     private JChartTitlesCustomizer titles;           // This view will customize all the titles
  21.     private JChartFormatCustomizer format;           // this view will customize the format of data presentation
  22.     
  23.  
  24.     // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  25.     // The constructor of this customizer
  26.     // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  27.     public JChartCustomizer() 
  28.     {   
  29.         setBackground(Color.lightGray);
  30.  
  31.         // create the tab viewer
  32.         tabViewer = new UITabViewer();
  33.  
  34.         // I have to host the UI objects before I can add them
  35.         AwtUIHost tabHost = new AwtUIHost(tabViewer);
  36.  
  37.         setLayout(null);
  38.  
  39.         // add the tab viewer to the customizer
  40.         add(tabHost);
  41.         setSize(500,400);
  42.         tabHost.setBounds(40,40, 400,200);
  43.  
  44.         // add the panel containing all the titles
  45.         titles = new JChartTitlesCustomizer();
  46.         tabViewer.add("Titles", titles);
  47.  
  48.         // add the panel containing the format customizer
  49.         format = new JChartFormatCustomizer();
  50.         tabViewer.add("Format", format );
  51.  
  52.     }
  53.  
  54.     // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  55.     // Interface Customizer requires the following methods to be defined
  56.     // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  57.  
  58.     /**
  59.      * Set the bean object which is to be customized
  60.      */
  61.     public void setObject(Object bean)
  62.     {
  63.  
  64.         // inform the other sub-customizers about this bean
  65.         titles.setObject(bean);
  66.         format.setObject(bean);
  67.     }
  68.  
  69.     /**
  70.      * Add a listener for changes to the bean
  71.      * @param   PropertyChangeListener  The object which should be informed of a change
  72.      */
  73.     public void addPropertyChangeListener(PropertyChangeListener listener)
  74.     {
  75.         // add this listener to the each of the view which are going to edit the properties
  76.         titles.addPropertyChangeListener(listener);
  77.         format.addPropertyChangeListener(listener);
  78.     }
  79.  
  80.     /**
  81.      * Remove a listener of bean property changes
  82.      * @param   PropertyChangeListener  The object who no longer wants to listen to changes
  83.      */
  84.     public void removePropertyChangeListener(PropertyChangeListener listener) 
  85.     {
  86.         // remove this listener from each of the views
  87.         titles.removePropertyChangeListener(listener);
  88.         format.removePropertyChangeListener(listener);
  89.     }
  90.  
  91. }
  92.