I have a fullscreen JFrame that I developed on my MacBook, and it worked great. The background was able to change colors and stuff. Now I moved it over to my Windows box and the background is white, and it doesn’t seem to want to change when I tell it to. Why could that be?
This is the code for setting up my windows (in a nutshell):
JFrame frame;
DisplayMode dm;
frame = new JFrame();
frame.setBackground(new Color(0.3F, 0.3F, 0.3F));
dm = new DisplayMode(Main.width, Main.height, 32, DisplayMode.REFRESH_RATE_UNKNOWN);
screen = new ScreenManager();
screen.setFullScreen(dm, frame);
This is the code for setting JFrames fullscreen.
import java.awt.DisplayMode;
import java.awt.GraphicsDevice;
import java.awt.GraphicsEnvironment;
import java.awt.Window;
import javax.swing.JFrame;
public class ScreenManager
{
public static GraphicsDevice vc;
public ScreenManager()
{
GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment();
vc = env.getDefaultScreenDevice();
}
public void setFullScreen(DisplayMode dm, JFrame window)
{
window.setUndecorated(true);
window.setResizable(false);
vc.setFullScreenWindow(window);
if (dm != null && vc.isDisplayChangeSupported())
{
try
{
vc.setDisplayMode(dm);
}
catch (IllegalArgumentException e)
{
//No need to do anything.
}
catch (Exception e)
{
e.printStackTrace();
}
}
}
}
The only thing I could think of is the JFrame is being set to a color–this won’t do anything.
Try this
You’d be setting the color of the pane itself instead of just the Frame.