home *** CD-ROM | disk | FTP | other *** search
/ Programming Languages Suite / ProgLangD.iso / VCAFE.3.0A / Sample.bin / JLookAndFeelAndPackFrameComboBox.java < prev    next >
Text File  |  1998-09-25  |  1KB  |  42 lines

  1. /*
  2.     A simple extension of the JLookAndFeelComboBox that pack()s the frame after swapping UIs
  3. */
  4. import java.io.*;
  5. import java.beans.*;
  6. import java.awt.*;
  7. import com.sun.java.swing.*;
  8. import com.symantec.itools.swing.*;
  9.  
  10. public class JLookAndFeelAndPackFrameComboBox extends com.symantec.itools.swing.JLookAndFeelComboBox implements java.io.Serializable
  11. {
  12.     public JLookAndFeelAndPackFrameComboBox()
  13.     {
  14.         super();
  15.     }
  16.  
  17.     public void run()
  18.     {
  19.         //Find top root pane
  20.         JRootPane topRoot = SwingUtilities.getRootPane(this);
  21.         if (topRoot != null)
  22.         {
  23.             while (true)
  24.             {
  25.                 Container rootParent = topRoot.getParent();
  26.                 if (rootParent == null)
  27.                     break;
  28.                 
  29.                 JRootPane possibleRoot = SwingUtilities.getRootPane(rootParent);
  30.                 if (possibleRoot == null || possibleRoot == topRoot)
  31.                     break;
  32.                 
  33.                 topRoot = possibleRoot;
  34.             }
  35.             SwingUtilities.updateComponentTreeUI(topRoot);
  36.             if(topRoot.getParent() instanceof Frame)
  37.             {
  38.                 ((Frame)topRoot.getParent()).pack();
  39.             }
  40.         }
  41.     }
  42. }