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 / Java2D / Java2DemoApplet.java < prev    next >
Encoding:
Java Source  |  1998-12-01  |  2.4 KB  |  82 lines

  1. /*
  2.  * @(#)Java2DemoApplet.java    1.9 98/09/13
  3.  *
  4.  * Copyright 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.  
  16. import java.awt.*;
  17. import javax.swing.*;
  18.  
  19.  
  20. public class Java2DemoApplet extends JApplet {
  21.  
  22.     static JApplet applet;
  23.  
  24.     public void init() {
  25.  
  26.         applet = this;
  27.  
  28.         JPanel panel = new JPanel();
  29.         getContentPane().add(panel,BorderLayout.CENTER);
  30.         panel.setLayout(new BoxLayout(panel, BoxLayout.X_AXIS));
  31.  
  32.         JPanel progressPanel = new JPanel() {
  33.             public Insets getInsets() {
  34.                 return new Insets(40,30,20,30);
  35.             }
  36.         };
  37.         progressPanel.setLayout(new BoxLayout(progressPanel, BoxLayout.Y_AXIS));
  38.  
  39.         panel.add(Box.createGlue());
  40.         panel.add(progressPanel);
  41.         panel.add(Box.createGlue());
  42.  
  43.         progressPanel.add(Box.createGlue());
  44.  
  45.         Dimension d = new Dimension(400, 20);
  46.         Java2Demo.progressLabel = new JLabel("Loading, please wait...");
  47.         Java2Demo.progressLabel.setMaximumSize(d);
  48.         progressPanel.add(Java2Demo.progressLabel);
  49.         progressPanel.add(Box.createRigidArea(new Dimension(1,20)));
  50.  
  51.         Java2Demo.progressBar = new JProgressBar();
  52.         Java2Demo.progressBar.setMaximumSize(d);
  53.         Java2Demo.progressBar.setMinimum(0);
  54.         Java2Demo.progressBar.setValue(0);
  55.         progressPanel.add(Java2Demo.progressBar);
  56.         progressPanel.add(Box.createGlue());
  57.         progressPanel.add(Box.createGlue());
  58.  
  59.         Rectangle ab = getContentPane().getBounds();
  60.         panel.setPreferredSize(new Dimension(ab.width,ab.height));
  61.         getContentPane().add(panel,BorderLayout.CENTER);
  62.         validate();
  63.         setVisible(true);
  64.  
  65.         Java2Demo.demo = new Java2Demo();
  66.         getContentPane().remove(panel);
  67.         getContentPane().setLayout(new BorderLayout());
  68.         getContentPane().add(Java2Demo.demo, BorderLayout.CENTER);
  69.         validate();
  70.         repaint();
  71.         Java2Demo.demo.requestDefaultFocus();
  72.     }
  73.  
  74.     public void start() {
  75.         Java2Demo.demo.start();
  76.     }
  77.  
  78.     public void stop() {
  79.         Java2Demo.demo.stop();
  80.     }
  81. }
  82.