When I run my bucky.java, the background color is black and not pink. Why?
Here is my bucky.java:-
import javax.swing.*;
import java.awt.*;
/**
* Created by IntelliJ IDEA.
* User: Administrator
* Date: 3/30/12
* Time: 3:59 PM
* To change this template use File | Settings | File Templates.
*/
public class bucky extends JFrame {
public static void main(String[] args){
DisplayMode dm = new DisplayMode(800, 600, 16, DisplayMode.REFRESH_RATE_UNKNOWN);
bucky b = new bucky();
b.run(dm);
}
public void run(DisplayMode dm) {
setBackground(new Color(234, 123, 66));
setForeground(Color.WHITE);
setFont(new Font("Arial", Font.PLAIN, 24));
Screen s = new Screen();
try {
s.setFullscreen(dm, this);
try{
Thread.sleep(5000);
}
catch(Exception e) {}
}
finally {
s.restoreWindow();
}
}
public void paint(Graphics g) {
if (g instanceof Graphics2D) {
Graphics2D g2D = (Graphics2D) g;
g2D.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
}
g.drawString("This is gonna be awesome!!!", 200, 200);
} }
Here is my Screen.java:-
import javax.swing.*;
import java.awt.*;
/**
* Created by IntelliJ IDEA.
* User: Administrator
* Date: 3/30/12
* Time: 3:29 PM
* To change this template use File | Settings | File Templates.
*/
public class Screen {
private GraphicsDevice vc;
public Screen() {
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 (Exception e) { }
}
}
public Window getFullScreenWindow() {
return vc.getFullScreenWindow();
}
public void restoreWindow() {
Window w = vc.getFullScreenWindow();
if (w != null) {
w.dispose();
}
vc.setFullScreenWindow(null);
}
}