如何使 window 小于 100 像素

How can I make window smaller than 100 pixels

我尝试在屏幕底部做一个状态栏,但是window不能小于100像素。我正在处理 Processing 3.0.1。

我使用下面的代码

void setup() {
      surface.setResizable(true);
      surface.setSize(300, 20);
      surface.setLocation(displayWidth-300, displayHeight-50);
    }

void draw() {
  background(128);
}

有什么想法吗??

提前谢谢大家

J!

如果去掉surface.setResizable(true);语句,可以看到canvas是300x20,而window不是:

Processing 3.0 有很多 changes 包括重构 windowing 代码,该代码以前依赖于 Java 的 AWT 包。

查看当前源码,可以看到:

static public final int MIN_WINDOW_WIDTH = 128;
static public final int MIN_WINDOW_HEIGHT = 128;

PSurface.java line 34 中定义 并贯穿 PSurfaceAWT.java 以确保这些最小 window 尺寸。

尝试访问 Surface 的 canvas (println(surface.getNative());) 我可以将其列为 processing.awt.PSurfaceAWT$SmoothCanvas 并且我可以看到 SmoothCanvas class with a getFrame() method 看起来很有希望,但事实并非如此'它似乎是可访问的(即使它是 public class 的 public 方法)。

所以默认情况下,此时,我会说在 Processing 3.x 中将 window 的大小调整为小于 128x128 是不行的。

如果 Processing 3.x 和更小的 window 是必须的,则可以自己调整源代码并重新编译核心库,但这可能会在以后有多个 Processing 项目时困扰您具有多个版本的处理核心库。我通常不建议修改核心库。

如果您可以为您的项目使用 Processing 2.x,使 window 尺寸小于 100 像素是可以实现的:

import java.awt.Dimension;

int w = 300;
int h = 20;
int appBarHeight = 23;//this is on OSX, on Windows/Linux this may be different

void setup() {
  size(w, h);
  frame.setResizable(true);
}

void draw() {
  if (frame.getHeight() != h+appBarHeight){//wait for Processing to finish setting up it's window dimensions (including minimum window dimensions)
    frame.setSize(w,h+appBarHeight);//set your dimensions
  }
  background(128);
}