jwindowtest2.java

来自「可以用的成绩管理系统」· Java 代码 · 共 75 行

JAVA
75
字号
/**
 * @(#)JWindowTest.java
 *
 *
 * @author 
 * @version 1.00 2008/7/18
 */

import javax.swing.JWindow;
import java.awt.*;
import javax.swing.*;
class MyJWindow extends JWindow{
	
	Image img;
	public MyJWindow(){
		
		 Dimension dim = Toolkit.getDefaultToolkit().getScreenSize();
	        try {
	                Robot r = new Robot();
	                Rectangle rect = new Rectangle(0, 0, dim.width, dim.height);
	                img = r.createScreenCapture(rect);
	        } catch (AWTException awe) {
	                System.out.println("robot excepton occurred");
	        }
	}
	public void paint(Graphics g) {
                g.drawImage(img, 0, 0, getWidth(), getHeight(), getX(), getY(), getX()
                                + getWidth(), getY() + getHeight(), this);
     }

     public void update(Graphics g) {
                paint(g);
     }
	
}

public class JWindowTest2 {
	
	static JWindow  window = null;
	JLabel jl =null;
	
	
    public JWindowTest2() {
    	window = new MyJWindow();
    	jl = new JLabel("<html><font color = red size= 24>欢迎使用本系统,你将成功登陆! </font></html>!");
    	
    
    	
  		
  		window.setLayout(new FlowLayout());
  		window.add(jl);
    	window.setSize(400,150);
    	//window.setLocation((int)(dim.getWidth()-window.getSize().getWidth())/2,(int)(dim.getHeight()-window.getSize().getHeight())/2);
    	window.setVisible(true);
    }
    
    
   
    
    public static void main(String[] args){
    	
    	new JWindowTest2();
    	
    	Thread t = Thread.currentThread();
    	try{
    		t.sleep(2000);
    		window.dispose();
    		//t.stop();
    	}catch(InterruptedException e){
    		
    		System.out.println(e);
    	}
    }
    
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?