简体   繁体   中英

How can I draw directly to screen?

Java是否可以使用Graphics上下文,以便程序员可以直接在屏幕上绘制而不是在窗口上绘制?

You can achieve pretty much what you describe (print arbitrary contents to an area of the screen of your choice) using SWT. The following snippet will display an empty rectangle (you can print arbitrary contents there eg using a Canvas).

Display display = new Display();
Shell shell = new Shell(SWT.NO_TRIM);
shell.setSize(50,50);
shell.setLocation(0,0); //show in upper left corner of main screen
//... add your custom contents
shell.open()
for(;!shell.isDisposed();)
  if(!display.readAndDispatch())
    display.sleep();

http://www.eclipse.org/swt/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM