Java Processing 2.0(使用Eclipse):从窗口切换到全屏和后退 [英] Java Processing 2.0 (Using Eclipse) : Switching from window to fullscreen and back

查看:1132
本文介绍了Java Processing 2.0(使用Eclipse):从窗口切换到全屏和后退的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Eclipse中使用了Processing 2.0,并且有一个关于正在运行的应用程序的窗口模式和全屏之间转换的问题(启动时未选择窗口或全屏,这很容易解决)。



这个问题解决了从Java处理到窗口模式的全屏模式的问题。



然而,我也想知道如何使用处理从窗口模式转换回全屏。有人有解决这个问题的办法吗?

解决方案

有点黑客,但你可以尝试创建一个单独的AWT框架,它是全屏的,并将Processing的小程序放入其中。通常,对于全屏,您只需要一个具有屏幕尺寸的框架,并且不需要装饰(标题栏,关闭按钮等)。捕获是在java.awt.Frame设置为可见(甚至是)后无法未装饰如果您将可见性设置为false,尝试重新整理,然后再重新生成框架),那么要解决这个问题,只需要一个单独的Frame实例,已经未装饰,并且正确的尺寸放在我们删除Processing的框架内容的位置。另外我们需要告诉处理更新的边界。



这是一个快速草图来说明这个想法(按f进行全屏):

  import java.awt.Frame; 
框架fullScreenFrame;
void setup(){
fullScreenFrame = new Frame();
fullScreenFrame.setUndecorated(true); //准备一个未装饰的全屏框架,因为java将不允许你在一个框架被设置为可视后未装饰
fullScreenFrame.setBounds(0,0,displayWidth, displayHeight);
fullScreenFrame.addKeyListener(getKeyListeners()[0]); //将密钥事件从此applet传递到fullScreen Frame
}
void draw(){
background((float )mouseX / width * 255,(float)mouseY / height * 255,0);
}
void keyReleased(){
if(key =='f'){
setBounds(0,0,displayWidth,displayHeight); //调整skech
fullScreenFrame.add(frame.getComponent(0)); //将Applet添加到Processing框架的全屏框架
fullScreenFrame.setVisible(true); //使我们的全屏框架可见
框架。 setVisible(false); //隐藏处理框架
}
}


I am using Processing 2.0 in Eclipse and have a question regarding the transition between windowed mode and fullscreen for a running application (not selecting windowed or fullscreen at startup, which is easily solved).

This question solves the problem of going from the fullscreen mode in Java Processing to windowed mode.

However, I would also like to know how to transition from windowed mode back to fullscreen using Processing. Does anyone have a solution to this problem?

解决方案

A bit hacky, but you can try creating a separate AWT Frame which is fullscreen and drop Processing's applet into it. Normally for fullscreen you should only need a frame with the screen dimensions and no decorations (title bar, close buttons, etc.) The catch is you can't 'undecorate' a java.awt.Frame after it's been set to visible (even if you set visibility to false, attempt to undecorate, then make the frame visible again), so to go around this will simply have a separate Frame instance, already undecorated and with the right dimensions into which we drop Processing's frame content. Also we need to tell processing the bounds are updated.

Here's a quick sketch to illustrate the idea(press 'f' for fullscreen):

import java.awt.Frame;
Frame fullScreenFrame;
void setup(){
  fullScreenFrame = new  Frame();
  fullScreenFrame.setUndecorated(true);//prepare an undecorated fullscreen frame since java won't allow you to 'undecorate' a frame after it's been set visible 
  fullScreenFrame.setBounds(0,0,displayWidth,displayHeight);
  fullScreenFrame.addKeyListener(getKeyListeners()[0]);//pass key events from this applet to the fullScreen Frame
}
void draw(){
  background((float)mouseX/width * 255,(float)mouseY/height * 255,0);
}
void keyReleased(){
  if(key == 'f') {
      setBounds(0,0,displayWidth,displayHeight);//resize the skech
      fullScreenFrame.add(frame.getComponent(0));//add the applet to the fullscreen frame from Processing's frame
      fullScreenFrame.setVisible(true);//make our fullscreen frame visible
      frame.setVisible(false );//and hide Processing's frame
   }
} 

这篇关于Java Processing 2.0(使用Eclipse):从窗口切换到全屏和后退的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆