我希望我的应用程序具有全屏模式.最简单的方法是,我需要第三方库吗?或者JDK中是否有提供此功能的东西?
我正在开发一个Cocoa Mac应用程序,我需要在辅助监视器上全屏显示窗口/视图.我知道如何创建一个可以拖到辅助监视器上的窗口,但我想以编程方式创建窗口并在外部监视器上全屏显示.谢谢您的帮助.
我的Java应用程序的片段:
JFrame f = new JFrame();
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsDevice gd = ge.getDefaultScreenDevice();
gd.setFullScreenWindow(f);
Run Code Online (Sandbox Code Playgroud)
所以它的作用是让它自动全屏.现在奇怪的是程序是全屏的,但只能在一台显示器上!例如,我有一个带有两个屏幕的Windows Vista系统,它们组合在一个桌面上.怎么做才能让它全屏显示所有显示器?
好的我试过了:
import java.awt.image.ColorModel;
import java.awt.GraphicsConfiguration;
import java.awt.GraphicsDevice;
import java.awt.GraphicsEnvironment;
import java.awt.Rectangle;
class grdevs
{
public static void main(String [] args)
{
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsDevice[] gs = ge.getScreenDevices();
for(GraphicsDevice curGs : gs)
{
GraphicsConfiguration[] gc = curGs.getConfigurations();
for(GraphicsConfiguration curGc : gc)
{
Rectangle bounds = curGc.getBounds();
ColorModel cm = curGc.getColorModel();
System.out.println("" + bounds.getX() + "," + bounds.getY() + " " + bounds.getWidth() …Run Code Online (Sandbox Code Playgroud) 在被动渲染模式中,可以使用KeyListener和ActionListener接口来处理来自用户的事件.
全屏模式下事件处理的正确方法是什么?请扩展此骨架,提供鼠标点击和按键事件的实现,请不要膨胀您的示例(示例启动全屏独占模式,使用Timer更新窗口中的图形):
import java.applet.Applet;
import java.awt.Color;
import java.awt.DisplayMode;
import java.awt.Graphics2D;
import java.awt.GraphicsConfiguration;
import java.awt.GraphicsDevice;
import java.awt.GraphicsEnvironment;
import java.awt.Rectangle;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.image.BufferStrategy;
import javax.swing.JFrame;
import javax.swing.Timer;
public class applet extends Applet
{
Timer timer;
JFrame frame;
DisplayMode[] displayModes = new DisplayMode[] {
new DisplayMode(1280, 800, 32, 60)
};
BufferStrategy bufferStrategy;
Rectangle bounds;
/**
*
*/
private static final long serialVersionUID = 1L;
/**
* @param args
*/
public void init()
{
GraphicsEnvironment …Run Code Online (Sandbox Code Playgroud) 我在"openSUSE 11.4(x86_64)"上以全屏模式运行Java应用程序时遇到问题.我使用的是Java 1.6.0_26-b03.
我尝试运行两个全屏应用程序示例:
在这两种情况下,我都可以在应用程序上看到一个Linux任务栏.它必须是系统设置/配置的东西?
我正在编写一个旨在双显示器设置上运行的应用程序,一台显示器上的"Display"JFrame全屏显示,另一台显示器上显示"Control"JFrame,向显示器发送指令.我尝试了两种不同的方法来设置全屏显示; 每个人的成功似乎取决于操作系统.
display.setUndecorated(true);
display.setExtendedState(JFrame.MAXIMIZED_BOTH);
Run Code Online (Sandbox Code Playgroud)
适用于Windows,但JFrame隐藏在OS X和Linux的dock/panels下.
我的另一种方法,利用
GraphicsDevice.setFullScreenWindow(display);
Run Code Online (Sandbox Code Playgroud)
适用于我尝试的所有三个操作系统,但在Windows中,将控制窗口聚焦在另一个监视器上会使显示窗口隐藏,并调用
display.setAlwaysOnTop(true);
Run Code Online (Sandbox Code Playgroud)
不解决问题.我对该GraphicsDevice方法有点偏爱,因为我不必处理OS X或Linux中的问题,我希望Windows问题是一个简单的修复.是吗?
我有一个带有片段的应用程序,在这些片段中我有框架布局,我添加了YouTubePlayerSupportFragment.但是当我点击全屏时会抛出此异常:
java.lang.RuntimeException:无法启动活动ComponentInfo {com.example.xxx/com.example.xxx.MainActivity}:java.lang.IllegalArgumentException:找不到id 0x7f040039的视图(com.example.xxx:id/frame_youtube)片段YouTubePlayerSupportFragment {4282a068#11 id = 0x7f040039}
我一直在网上搜索我的全屏javascript在Safari中不起作用的原因,但在webkit浏览器Chrome中有效.似乎safari不支持element.ALLOW_KEYBOARD_INPUT附加组件webkitRequestFullScreen.
function cancelFullScreen(el) {
var requestMethod = el.cancelFullScreen || el.webkitCancelFullScreen || el.mozCancelFullScreen || el.exitFullscreen;
if (requestMethod) { // cancel full screen.
requestMethod.call(el);
} else if (typeof window.ActiveXObject !== "undefined") { // Older IE.
var wscript = new ActiveXObject("WScript.Shell");
if (wscript !== null) {
wscript.SendKeys("{F11}");
}
}
}
function requestFullScreen(el) {
// Supports most browsers and their versions.
var requestMethod = el.requestFullScreen || el.webkitRequestFullScreen(el.ALLOW_KEYBOARD_INPUT) || el.mozRequestFullScreen || el.msRequestFullScreen;
if (requestMethod) { // Native full screen.
requestMethod.call(el);
} …Run Code Online (Sandbox Code Playgroud) 是否有任何方法可以使全屏(如果可能的话也调整大小)而不是重新排列所有内容(实际上它的作用是重新排列元素,如调整大小但是整个屏幕)以制作实际的全屏模式?(比如通常做的游戏就是更改屏幕分辨率),因此按钮和文本会根据屏幕/窗口的大小而增长
另外如何删除消息和效果点击"esc"键退出全屏模式?
编辑:使用这种方式使可调整大小
@Override public void start(Stage stage) throws Exception{
final int initWidth = 720; //initial width
final int initHeight = 1080; //initial height
final Pane root = new Pane(); //necessary evil
Pane controller = new CtrlMainMenu(); //initial view
controller.setPrefWidth(initWidth); //if not initialized
controller.setPrefHeight(initHeight); //if not initialized
root.getChildren().add(controller); //necessary evil
Scale scale = new Scale(1, 1, 0, 0);
scale.xProperty().bind(root.widthProperty().divide(initWidth)); //must match with the one in the controller
scale.yProperty().bind(root.heightProperty().divide(initHeight)); //must match with the one in the controller
root.getTransforms().add(scale);
final Scene scene …Run Code Online (Sandbox Code Playgroud) 我想让我的网络应用隐藏Chrome移动版上的浏览器标签和地址栏.document.documentElement.requestFullScreen()似乎没有效果.window.scroll(0,1)在平板电脑上也不起作用.
如果可能的话,我也会喜欢iOS上的Chrome和/或Safari的好解决方案.
有任何想法吗?我使用的是Chrome 29 for Android.