Hello!
I've been looking into running fullscreen applications in java, and I went on and tried to run this:
import javax.swing.JFrame;
import javax.swing.JPanel;
import java.awt.*;
public class Main extends JFrame{
public static final String TITLE = "Pong";
public static final String VERSION = "1.0";
public static void main(String[] args) {
JFrame window = new JFrame();
window.setUndecorated(true);
window.setResizable(false);
window.setBackground(Color.BLUE);
window.setForeground(Color.WHITE);
DisplayMode dm = new DisplayMode(800, 600, 16, 60);
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsDevice gd = ge.getDefaultScreenDevice();
gd.setFullScreenWindow(window);
try {
gd.setDisplayMode(dm);
}
catch(IllegalArgumentException ex) {
System.out.print("Illegal Display Mode");
}
try {
Thread.sleep(5000);
}
catch (Exception ex) {
ex.printStackTrace();
}
gd.setFullScreenWindow(null);
}
public void paintComponent(Graphics g) {
System.out.print("Paint Method Called");
g.drawString("Fullscreen", 50, 50);
}
}
The problem here, is that I couldn't get the paint method to be called. Why is that?