Java代码
唤乱喊import java awt Color
import java awt DisplayMode
import java awt Font
import java awt Graphics
import javax swing JFrame
public class FullScreenTest extends JFrame {
public static void main(String[] args) {
DisplayMode displayMode
if (args length == ) {
displayMode = new DisplayMode(
Integer parseInt(args[ ])
Integer parseInt(args[ ])
Integer parseInt(args[ ])
DisplayMode REFRESH_RATE_UNKNOWN)
}
陪氏 else {
displayMode = new DisplayMode(
DisplayMode REFRESH_RATE_UNKNOWN)
}
FullScreenTest test = new FullScreenTest()
test run(displayMode)
}
private static final long DEMO_TIME =
public void run(DisplayMode displayMode) {
setBackground(Color blue)
setForeground(Color white)
setFont(new Font( Dialog Font PLAIN ))
SimpleScreenManager screen = new SimpleScreenManager()
try {
screen setFullScreen(displayMode this)
try {
Thread sleep(DEMO_TIME)
}
catch (InterruptedException ex) { }
}
finally {
screen restoreScreen()
}
}
public void paint(Graphics g) {
g drawString( Hello World! )
}
}
Java代码
import java awt DisplayMode
import java awt GraphicsDevice
import java awt GraphicsEnvironment
import java awt Window
import javax swing JFrame
/**
* The SimpleScreenManager class manages initializing and displaying full screen
* graphics modes
*/
public class SimpleScreenManager {
private GraphicsDevice device
/**
* Creates a new SimpleScreenManager object
*/
public SimpleScreenManager() {
GraphicsEnvironment environment = GraphicsEnvironment
getLocalGraphicsEnvironment()
device = environment getDefaultScreenDevice()
和野 }
/**
* Enters full screen mode and changes the display mode
*/
public void setFullScreen(DisplayMode displayMode JFrame window) {
window setUndecorated(true)
window setResizable(false)
device setFullScreenWindow(window)
if (displayMode != null &&device isDisplayChangeSupported()) {
try {
device setDisplayMode(displayMode)
} catch (IllegalArgumentException ex) {
// ignore illegal mode for this device
}
}
}
/**
* Returns the window currently used in full screen mode
*/
public Window getFullScreenWindow() {
return device getFullScreenWindow()
}
/**
* Restores the screen s display mode
*/
public void restoreScreen() {
Window window = device getFullScreenWindow()
if (window != null) {
window dispose()
}
device setFullScreenWindow(null)
}
lishixinzhi/Article/program/Java/hx/201311/26128创建一个JFrame ,设置成undecorated,设置bounds为凳梁数屏幕大小
//import 如下:
import java.awt.Dimension
import java.awt.Rectangle
import java.awt.Toolkit
import javax.swing.JFrame
代码如下:
JFrame frame = new JFrame()
frame.setUndecorated(true)
/枣首/ 取得屏渣派幕大小
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize()
Rectangle bounds = new Rectangle( screenSize )
frame.setBounds( bounds )
frame.setVisibale(true)
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)