import javax.swing.*;
import java.awt.*;
class jframtest {
public static void main (String[] args) {
JFrame myFrame = new JFrame();
myFrame.setDefaultLookAndFeelDecorated(true);
myFrame.setBackground(Color.BLACK);
myFrame.setSize(400,400);
myFrame.setVisible(true);
}
}
I tried that and it didn't work either, so I investigated on it and found out:
The method "JFrame.setBackground()" has been deprecated on Swing.
In other words, everything about the JFrame relating to it being a container has been rendered void of use. Instead, you have to call javax.swing.JFrame.getContentPane() and use that container.
I tried this and it worked:
import javax.swing.*;
import java.awt.*;
class javaframetest {
public static void main (String[] args) {
JFrame myFrame = new JFrame();
myFrame.setDefaultLookAndFeelDecorated(true);
myFrame.getContentPane().setBackground(Color.BLACK);
myFrame.setSize(400,400);
myFrame.setVisible(true);
}
}