📄 jwindowtest2.java
字号:
/**
* @(#)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 + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -