Skip to Main Content

New to Java

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How to use the setBackground() method? (JFrame)

807600Jun 26 2007 — edited Jun 27 2007
I'm want to make a JFrame with black background.

I tried to use the setBackground() method, but didn't work.
The background changes to black, but after it returns to white(quickly).

Here's my code:
// ***********************
// Game.java
// ***********************
import javax.swing.*;
import java.awt.*;

public class Game {
	public static void main (String args[]){
		JFrame window = new JFrame("Bruno's Game");
		window.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
		window.setSize(320,240);

		window.setLayout( null );

		window.setBackground( new Color(0,0,0) );

		window.setVisible( true );
	}
}
Does anyone have some tips?

Thank's.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jul 25 2007
Added on Jun 26 2007
2 comments
274 views