package 
   sample;

 
  import 
   java.awt. 
  * 
  ;
 
  import 
   java.awt.Robot;
 
  import 
   javax.swing. 
  * 
  ;

 
  public 
    
  final 
    
  class 
   Test  
  extends 
   JApplet  
  ... 
  {

   JPanel jp;
   
   Image Background;
   Point p0;
   Point p1;
   
   public Test() ...{
       jp = new JPanel();
       this.getContentPane().add(jp);
    //获取整个屏幕图像
       try ...{
           Robot r = new Robot();
           Toolkit tk =Toolkit.getDefaultToolkit();
           Dimension dm = tk.getScreenSize();
           Background = r.createScreenCapture(new Rectangle(0,0,(int)dm.getWidth(), (int)dm.getHeight()));
       } catch(Exception e) ...{
           e.printStackTrace();
       }
       this.resize(600, 600);
       this.setVisible(true);
   }
   
   public void paint(Graphics g) ...{
       p0 = this.getLocationOnScreen();
       p1 = new Point(-p0.x, -p0.y);
       g.drawImage(Background, p1.x, p1.y, null);
       repaint();
   }
}