-
Bug
-
Resolution: Not an Issue
-
P4
-
7u51
-
x86_64
-
windows_vista
FULL PRODUCT VERSION :
java version "1.7.0_51"
Java(TM) SE Runtime Environment (build 1.7.0_51-b13)
Java HotSpot(TM) 64-Bit Server VM (build 24.51-b03, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows [Version 6.1.7601]
EXTRA RELEVANT SYSTEM CONFIGURATION :
Graphics Device: Nvidia GeForce GTS 240
Graphics Driver Version: 334.89
Using Dual Monitor setup.
Internet Explorer Version: 9.0.8112.16421
A DESCRIPTION OF THE PROBLEM :
When running a Frame in FSEM certain resolutions don't seem to scale correctly to full-screen.
Tested 1280xN resolutions (1280x720, 1280x800, 1280x960) all have the same issue. Height doesn't seem to scale so the resulting image is stretched horizontally and letter box style black strips are left at the top and bottom.
One other tested resolution 1680x1050 had the opposite issue, horizontal scaling doesn't happen correctly.
These resolutions are all listed by the GraphicsDevice as being valid.
Tested cases behave the same regardless of applet or application.
Attempts to take a screenshot with Alt+PrtScr supplied an image of the correct resolutions without the letter box behaviour.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Create Frame from an application and set it as the window for FSEM.
Use a DisplayMode based on one of the resolutions 1280x720, 1280x800, 1280x960 or 1680x1050.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Frame fills the screen entirely leaving no spaces.
ACTUAL -
Frame is letter boxed in one of it's dimensions leaving black borders on the relevant edges. The other dimension is stretched to full-screen.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
public class Main {
public static void main(String[] args) {
try {
GraphicsDevice device = GraphicsEnvironment
.getLocalGraphicsEnvironment().getDefaultScreenDevice();
new FullScreenResolutionTest(device);
} catch (Exception e) {
e.printStackTrace();
}
System.exit(0);
}
}
import java.awt.Color;
import java.awt.DisplayMode;
import java.awt.Frame;
import java.awt.Graphics;
import java.awt.GraphicsConfiguration;
import java.awt.GraphicsDevice;
import java.awt.image.BufferStrategy;
import javax.swing.JFrame;
public class FullScreenResolutionTest {
private static final int NUM_BUFFERS = 2;
public static final Color[] COLORS = new Color[] { Color.red, Color.green, Color.blue};
private static final int[][] RESOLUTIONS = new int[][]
{
new int[]{1024, 768},
new int[]{1280, 720},
new int[]{1280, 800},
new int[]{1280, 960},
new int[]{1680, 1050},
new int[]{1366, 768}
};
private final GraphicsDevice device;
private Frame mainFrame;
private BufferStrategy bufferStrategy;
private DisplayMode currentDisplayMode;
private int resolutionIndex;
public FullScreenResolutionTest(GraphicsDevice device) {
this.device = device;
this.resolutionIndex = 0;
try {
GraphicsConfiguration gc = device.getDefaultConfiguration();
mainFrame = new JFrame(gc);
mainFrame.setUndecorated(true);
mainFrame.setIgnoreRepaint(true);
mainFrame.setResizable(false);
device.setFullScreenWindow(mainFrame);
chooseNextDisplayMode();
mainFrame.createBufferStrategy(NUM_BUFFERS);
bufferStrategy = mainFrame.getBufferStrategy();
display();
} catch (Exception e) {
e.printStackTrace();
} finally {
device.setFullScreenWindow(null);
}
}
public void display() {
for (; resolutionIndex < RESOLUTIONS.length;) {
for (int i = 0; i < COLORS.length; i++) {
for(int count = 0; count < 10; count++)
{
Graphics g = bufferStrategy.getDrawGraphics();
if (!bufferStrategy.contentsLost()) {
g.setColor(COLORS[i]);
g.fillRect(0, 0, currentDisplayMode.getWidth(), currentDisplayMode.getHeight());
g.setColor(Color.white);
g.drawString("Width: " + currentDisplayMode.getWidth() + " Height: " + currentDisplayMode.getHeight(), 20, 20);
bufferStrategy.show();
}
g.dispose();
try {
Thread.sleep(200);
} catch (InterruptedException e) {
}
}
}
resolutionIndex++;
chooseNextDisplayMode();
}
}
private void chooseNextDisplayMode()
{
if(resolutionIndex >= RESOLUTIONS.length)
return;
int[] resolution = RESOLUTIONS[resolutionIndex];
DisplayMode best = getBestDisplayMode(device,
new DisplayMode(resolution[0], resolution[1], 32, DisplayMode.REFRESH_RATE_UNKNOWN),
new DisplayMode(resolution[0], resolution[1], 16, DisplayMode.REFRESH_RATE_UNKNOWN),
new DisplayMode(resolution[0], resolution[1], 8, DisplayMode.REFRESH_RATE_UNKNOWN));
if (best != null) {
device.setDisplayMode(best);
currentDisplayMode = best;
}
else {
resolutionIndex++;
chooseNextDisplayMode();
}
}
private DisplayMode getBestDisplayMode(GraphicsDevice device, DisplayMode... displayModes) {
for (int x = 0; x < displayModes.length; x++) {
DisplayMode[] modes = device.getDisplayModes();
for (int i = 0; i < modes.length; i++) {
DisplayMode displayMode = displayModes[x];
if (modes[i].getWidth() == displayMode.getWidth()
&& modes[i].getHeight() == displayMode.getHeight()
&& modes[i].getBitDepth() == displayMode.getBitDepth()) {
return displayMode;
}
}
}
return null;
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Only solution seems to be not to use these resolutions. Less than ideal as 1280x720 particularly is a commonly used resolution.
java version "1.7.0_51"
Java(TM) SE Runtime Environment (build 1.7.0_51-b13)
Java HotSpot(TM) 64-Bit Server VM (build 24.51-b03, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows [Version 6.1.7601]
EXTRA RELEVANT SYSTEM CONFIGURATION :
Graphics Device: Nvidia GeForce GTS 240
Graphics Driver Version: 334.89
Using Dual Monitor setup.
Internet Explorer Version: 9.0.8112.16421
A DESCRIPTION OF THE PROBLEM :
When running a Frame in FSEM certain resolutions don't seem to scale correctly to full-screen.
Tested 1280xN resolutions (1280x720, 1280x800, 1280x960) all have the same issue. Height doesn't seem to scale so the resulting image is stretched horizontally and letter box style black strips are left at the top and bottom.
One other tested resolution 1680x1050 had the opposite issue, horizontal scaling doesn't happen correctly.
These resolutions are all listed by the GraphicsDevice as being valid.
Tested cases behave the same regardless of applet or application.
Attempts to take a screenshot with Alt+PrtScr supplied an image of the correct resolutions without the letter box behaviour.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Create Frame from an application and set it as the window for FSEM.
Use a DisplayMode based on one of the resolutions 1280x720, 1280x800, 1280x960 or 1680x1050.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Frame fills the screen entirely leaving no spaces.
ACTUAL -
Frame is letter boxed in one of it's dimensions leaving black borders on the relevant edges. The other dimension is stretched to full-screen.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
public class Main {
public static void main(String[] args) {
try {
GraphicsDevice device = GraphicsEnvironment
.getLocalGraphicsEnvironment().getDefaultScreenDevice();
new FullScreenResolutionTest(device);
} catch (Exception e) {
e.printStackTrace();
}
System.exit(0);
}
}
import java.awt.Color;
import java.awt.DisplayMode;
import java.awt.Frame;
import java.awt.Graphics;
import java.awt.GraphicsConfiguration;
import java.awt.GraphicsDevice;
import java.awt.image.BufferStrategy;
import javax.swing.JFrame;
public class FullScreenResolutionTest {
private static final int NUM_BUFFERS = 2;
public static final Color[] COLORS = new Color[] { Color.red, Color.green, Color.blue};
private static final int[][] RESOLUTIONS = new int[][]
{
new int[]{1024, 768},
new int[]{1280, 720},
new int[]{1280, 800},
new int[]{1280, 960},
new int[]{1680, 1050},
new int[]{1366, 768}
};
private final GraphicsDevice device;
private Frame mainFrame;
private BufferStrategy bufferStrategy;
private DisplayMode currentDisplayMode;
private int resolutionIndex;
public FullScreenResolutionTest(GraphicsDevice device) {
this.device = device;
this.resolutionIndex = 0;
try {
GraphicsConfiguration gc = device.getDefaultConfiguration();
mainFrame = new JFrame(gc);
mainFrame.setUndecorated(true);
mainFrame.setIgnoreRepaint(true);
mainFrame.setResizable(false);
device.setFullScreenWindow(mainFrame);
chooseNextDisplayMode();
mainFrame.createBufferStrategy(NUM_BUFFERS);
bufferStrategy = mainFrame.getBufferStrategy();
display();
} catch (Exception e) {
e.printStackTrace();
} finally {
device.setFullScreenWindow(null);
}
}
public void display() {
for (; resolutionIndex < RESOLUTIONS.length;) {
for (int i = 0; i < COLORS.length; i++) {
for(int count = 0; count < 10; count++)
{
Graphics g = bufferStrategy.getDrawGraphics();
if (!bufferStrategy.contentsLost()) {
g.setColor(COLORS[i]);
g.fillRect(0, 0, currentDisplayMode.getWidth(), currentDisplayMode.getHeight());
g.setColor(Color.white);
g.drawString("Width: " + currentDisplayMode.getWidth() + " Height: " + currentDisplayMode.getHeight(), 20, 20);
bufferStrategy.show();
}
g.dispose();
try {
Thread.sleep(200);
} catch (InterruptedException e) {
}
}
}
resolutionIndex++;
chooseNextDisplayMode();
}
}
private void chooseNextDisplayMode()
{
if(resolutionIndex >= RESOLUTIONS.length)
return;
int[] resolution = RESOLUTIONS[resolutionIndex];
DisplayMode best = getBestDisplayMode(device,
new DisplayMode(resolution[0], resolution[1], 32, DisplayMode.REFRESH_RATE_UNKNOWN),
new DisplayMode(resolution[0], resolution[1], 16, DisplayMode.REFRESH_RATE_UNKNOWN),
new DisplayMode(resolution[0], resolution[1], 8, DisplayMode.REFRESH_RATE_UNKNOWN));
if (best != null) {
device.setDisplayMode(best);
currentDisplayMode = best;
}
else {
resolutionIndex++;
chooseNextDisplayMode();
}
}
private DisplayMode getBestDisplayMode(GraphicsDevice device, DisplayMode... displayModes) {
for (int x = 0; x < displayModes.length; x++) {
DisplayMode[] modes = device.getDisplayModes();
for (int i = 0; i < modes.length; i++) {
DisplayMode displayMode = displayModes[x];
if (modes[i].getWidth() == displayMode.getWidth()
&& modes[i].getHeight() == displayMode.getHeight()
&& modes[i].getBitDepth() == displayMode.getBitDepth()) {
return displayMode;
}
}
}
return null;
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Only solution seems to be not to use these resolutions. Less than ideal as 1280x720 particularly is a commonly used resolution.