From 3f0e49c1dd8555f331fc21aaedb6875de084cb9c Mon Sep 17 00:00:00 2001 From: Ben Fry Date: Sun, 21 Jun 2015 14:17:29 -0400 Subject: [PATCH] trying with Frame instead of JFrame --- core/src/processing/core/PApplet.java | 55 ++++++++++++----------- core/src/processing/core/PSurfaceAWT.java | 12 ++++- core/todo.txt | 2 + 3 files changed, 41 insertions(+), 28 deletions(-) diff --git a/core/src/processing/core/PApplet.java b/core/src/processing/core/PApplet.java index 43d06718c..b282933ea 100644 --- a/core/src/processing/core/PApplet.java +++ b/core/src/processing/core/PApplet.java @@ -24,9 +24,9 @@ package processing.core; -// these are used for various methods (url opening, file selection, etc) -// how many more can we remove? +// used by link() import java.awt.Desktop; + import java.awt.DisplayMode; import java.awt.EventQueue; import java.awt.FileDialog; @@ -42,8 +42,11 @@ import java.awt.image.BufferedImage; // used by loadImage() functions import javax.imageio.ImageIO; +// allows us to remove our own MediaTracker code import javax.swing.ImageIcon; +// used by selectInput(), selectOutput(), selectFolder() import javax.swing.JFileChooser; +// used to present the fullScreen() warning about Spaces on OS X import javax.swing.JOptionPane; // used by desktopFile() method import javax.swing.filechooser.FileSystemView; @@ -322,19 +325,19 @@ public class PApplet implements PConstants { /** * ( begin auto-generated from pixelWidth.xml ) * - * When pixelDensity(2) is used to make use of a high resolution - * display (called a Retina display on OS X or high-dpi on Windows and - * Linux), the width and height of the sketch do not change, but the - * number of pixels is doubled. As a result, all operations that use pixels - * (like loadPixels(), get(), set(), etc.) happen - * in this doubled space. As a convenience, the variables pixelWidth - * and pixelHeight hold the actual width and height of the sketch - * in pixels. This is useful for any sketch that uses the pixels[] - * array, for instance, because the number of elements in the array will + * When pixelDensity(2) is used to make use of a high resolution + * display (called a Retina display on OS X or high-dpi on Windows and + * Linux), the width and height of the sketch do not change, but the + * number of pixels is doubled. As a result, all operations that use pixels + * (like loadPixels(), get(), set(), etc.) happen + * in this doubled space. As a convenience, the variables pixelWidth + * and pixelHeight hold the actual width and height of the sketch + * in pixels. This is useful for any sketch that uses the pixels[] + * array, for instance, because the number of elements in the array will * be pixelWidth*pixelHeight, not width*height. * * ( end auto-generated ) - * + * * @webref environment * @see PApplet#pixelWidth * @see pixelDensity() @@ -342,23 +345,23 @@ public class PApplet implements PConstants { */ public int pixelWidth; - + /** * ( begin auto-generated from pixelHeight.xml ) * - * When pixelDensity(2) is used to make use of a high resolution - * display (called a Retina display on OS X or high-dpi on Windows and - * Linux), the width and height of the sketch do not change, but the - * number of pixels is doubled. As a result, all operations that use pixels - * (like loadPixels(), get(), set(), etc.) happen - * in this doubled space. As a convenience, the variables pixelWidth - * and pixelHeight hold the actual width and height of the sketch - * in pixels. This is useful for any sketch that uses the pixels[] - * array, for instance, because the number of elements in the array will + * When pixelDensity(2) is used to make use of a high resolution + * display (called a Retina display on OS X or high-dpi on Windows and + * Linux), the width and height of the sketch do not change, but the + * number of pixels is doubled. As a result, all operations that use pixels + * (like loadPixels(), get(), set(), etc.) happen + * in this doubled space. As a convenience, the variables pixelWidth + * and pixelHeight hold the actual width and height of the sketch + * in pixels. This is useful for any sketch that uses the pixels[] + * array, for instance, because the number of elements in the array will * be pixelWidth*pixelHeight, not width*height. * * ( end auto-generated ) - * + * * @webref environment * @see PApplet#pixelHeight * @see pixelDensity() @@ -1096,9 +1099,9 @@ public class PApplet implements PConstants { /** * ( begin auto-generated from displayDensity.xml ) * - * This function returns the number "2" if the screen is a high-density - * screen (called a Retina display on OS X or high-dpi on Windows and Linux) - * and a "1" if not. This information is useful for a program to adapt to + * This function returns the number "2" if the screen is a high-density + * screen (called a Retina display on OS X or high-dpi on Windows and Linux) + * and a "1" if not. This information is useful for a program to adapt to * run at double the pixel density on a screen that supports it. * * ( end auto-generated ) diff --git a/core/src/processing/core/PSurfaceAWT.java b/core/src/processing/core/PSurfaceAWT.java index 7f7b7f9f3..423814807 100644 --- a/core/src/processing/core/PSurfaceAWT.java +++ b/core/src/processing/core/PSurfaceAWT.java @@ -43,7 +43,11 @@ public class PSurfaceAWT extends PSurfaceNone { // boolean resizable; // default is false // Internally, we know it's always a JFrame (not just a Frame) - JFrame frame; +// JFrame frame; + // Trying Frame again with a11 to see if this avoids some Swing nastiness. + // In the past, AWT Frames caused some problems on Windows and Linux, + // but those may not be a problem for our reworked PSurfaceAWT class. + Frame frame; // Note that x and y may not be zero, depending on the display configuration Rectangle screenRect; @@ -487,7 +491,11 @@ public class PSurfaceAWT extends PSurfaceNone { // backgroundColor = WINDOW_BGCOLOR; // } final Color windowColor = new Color(sketch.sketchWindowColor(), false); - frame.getContentPane().setBackground(windowColor); + if (frame instanceof JFrame) { + ((JFrame) frame).getContentPane().setBackground(windowColor); + } else { + frame.setBackground(windowColor); + } // Put the p5 logo in the Frame's corner to override the Java coffee cup. setIconImage(frame); diff --git a/core/todo.txt b/core/todo.txt index 23f00b971..8c36c71b2 100644 --- a/core/todo.txt +++ b/core/todo.txt @@ -41,6 +41,8 @@ X setUndecorated(boolean) X setting menubar will be surface-specific X setLocation(int, int) and setSize(int, int) X add the "don't use this" warning to the JFrame in PSurfaceAWT +X ArithmeticException: / by zero when using fonts opened with loadFont() +X https://github.com/processing/processing/issues/3413 threading headaches X sketch not always showing with empty draw()