home *** CD-ROM | disk | FTP | other *** search
/ Programming Languages Suite / ProgramD2.iso / J A V A / Java Development Kit V1.2 / jdk12-win32(1).exe / data1.cab / demos / demo / jfc / SwingSet / SwingSetApplet.java < prev    next >
Encoding:
Java Source  |  1998-12-01  |  3.0 KB  |  93 lines

  1. /*
  2.  * @(#)SwingSetApplet.java    1.10 98/08/26
  3.  *
  4.  * Copyright 1997, 1998 by Sun Microsystems, Inc.,
  5.  * 901 San Antonio Road, Palo Alto, California, 94303, U.S.A.
  6.  * All rights reserved.
  7.  *
  8.  * This software is the confidential and proprietary information
  9.  * of Sun Microsystems, Inc. ("Confidential Information").  You
  10.  * shall not disclose such Confidential Information and shall use
  11.  * it only in accordance with the terms of the license agreement
  12.  * you entered into with Sun.
  13.  */
  14.  
  15. import javax.swing.*;
  16. import javax.swing.event.*;
  17. import javax.swing.text.*;
  18. import javax.swing.border.*;
  19. import java.awt.*;
  20. import java.awt.event.*;
  21. import java.util.*;
  22. import java.io.*;
  23.  
  24. import java.applet.*;
  25. import SwingSet;
  26.  
  27. public class SwingSetApplet extends JApplet {
  28.     JPanel panel;
  29.     
  30.     public void init() {
  31.  
  32.         String vers = System.getProperty("java.version");
  33.         final Applet thisApplet = this;
  34.  
  35.         if (vers.compareTo("1.1.2") < 0) {
  36.             System.out.println("!!!WARNING: Swing must be run with a " +
  37.                                "1.1.2 or higher version VM!!!");
  38.         }
  39.  
  40.     // Force SwingSet to come up in the Cross Platform L&F
  41.     try {
  42.         UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName());
  43.         // If you want the System L&F instead, comment out the above line and
  44.         // uncomment the following:
  45.         // UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
  46.     } catch (Exception exc) {
  47.         System.err.println("Error loading L&F: " + exc);
  48.     }
  49.  
  50.         panel = new JPanel();
  51.         getContentPane().add(panel,BorderLayout.CENTER);
  52.         panel.setLayout(new BoxLayout(panel, BoxLayout.X_AXIS));
  53.  
  54.         JPanel progressPanel = SwingSet.createVerticalPanel(false);
  55.         panel.add(Box.createGlue());
  56.         panel.add(progressPanel);
  57.         panel.add(Box.createGlue());
  58.  
  59.         progressPanel.add(Box.createGlue());
  60.  
  61.         Dimension d = new Dimension(400, 20);
  62.         SwingSet.progressLabel = new JLabel("Loading, please wait...");
  63.         SwingSet.progressLabel.setMaximumSize(d);
  64.         progressPanel.add(SwingSet.progressLabel);
  65.         progressPanel.add(Box.createRigidArea(new Dimension(1,20)));
  66.  
  67.         SwingSet.progressBar = new JProgressBar();
  68.         SwingSet.progressBar.setMaximumSize(d);
  69.         SwingSet.progressBar.setMinimum(0);
  70.         SwingSet.progressBar.setMaximum(SwingSet.totalPanels);
  71.         SwingSet.progressBar.setValue(0);
  72.         progressPanel.add(SwingSet.progressBar);
  73.         progressPanel.add(Box.createGlue());
  74.         progressPanel.add(Box.createGlue());
  75.  
  76.         // show the panel
  77.         Rectangle ab = getContentPane().getBounds();
  78.         panel.setPreferredSize(new Dimension(ab.width,ab.height));
  79.         getContentPane().add(panel,BorderLayout.CENTER);
  80.         validate();
  81.         setVisible(true);
  82.  
  83.         SwingSet sw = new SwingSet(thisApplet);
  84.         getContentPane().remove(panel);
  85.         getContentPane().setLayout(new BorderLayout());
  86.         getContentPane().add(sw, BorderLayout.CENTER);
  87.         validate();
  88.         repaint();
  89.         sw.requestDefaultFocus();
  90.     }
  91. }
  92.  
  93.