可以用一个全屏工作的窗口来模拟,
建立一个Robot对象来控制鼠标和键盘,
当接收到某些命令后退出全屏即可
--------------------------------
//FullScreen.java
//10秒后恢复正常,也可用事件来代替10秒的等待
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.GraphicsDevice;
import java.awt.Point;
import java.awt.Rectangle;
import java.awt.Robot;
import java.awt.event.KeyEvent;
import java.awt.image.BufferedImage;
import javax.swing.ImageIcon;
import javax.swing.JLabel;
import javax.swing.JWindow;
public class FullScreen extends JWindow implements Runnable{
private static final long serialVersionUID = -5618427811776470187L;
private Robot robot;
private long startTime = System.currentTimeMillis();
private BufferedImage desktop;
private JLabel bg;
public FullScreen(){
try{robot = new Robot();}catch(Exception e){}
desktop=robot.createScreenCapture(new Rectangle(
0,0,
getToolkit().getScreenSize().width,
getToolkit().getScreenSize().height));
//将窗口内容设置成程序启动前一瞬间的屏幕内容,这样来欺骗我们的眼睛
bg = new JLabel(new ImageIcon(desktop));
this.getContentPane().setLayout(new BorderLayout());
this.getContentPane().add(bg);
this.setVisible(true);
this.setFocusable(true);
BufferedImage cursorImage = new BufferedImage(1,1,2);
Graphics2D g = cursorImage.createGraphics();
g.setBackground(new Color(0,true));
g.setColor(g.getBackground());
g.fillRect(0,0,1,1);
g.dispose();
//将鼠标设置成一个透明的,呵呵,这样就看不到鼠标了咯
this.setCursor(this.getToolkit().createCustomCursor(cursorImage, new Point(0,0),"transCursor"));
new Thread(this).start();
//全屏显示本窗口实例
GraphicsDevice dev = this.getGraphicsConfiguration().getDevice();;
dev.setFullScreenWindow(this);
}
//键盘不断按ESC键,这样好多命令就不能正常启用,将键盘带来的干扰降低
//当然也可以加入更多的按键,对命令行程序更有用,(我是LINUX系统的,基本在命令下工作)
private void pressKeys(){
robot.keyPress(KeyEvent.VK_ESCAPE);
robot.keyRelease(KeyEvent.VK_ESCAPE);
}
public void run() {
while(true){
try {Thread.sleep(10);} catch (Exception e) {}
// 10秒钟后退出程序,这里也可以用其它事件来处理
if(System.currentTimeMillis()-startTime<10000){
pressKeys();
continue;
}
this.getGraphicsConfiguration().getDevice().setFullScreenWindow(null);
this.dispose();
System.exit(0);
}
}
public static void main(String[] args) {
new FullScreen();
}
}
用java自身是不可能的,因为这种操作有很高的平台依赖,java肯定不会实现。用jni也许可以吧,在c++中应该能调用api实现。具体的不知道,我是研究java me的
帮不了你,望能见谅!JAVA好像办不到这点,它做游戏很行的。