我用setBackground(Color.black)想将背景设置为黑色,为什么没成功了 ?
import javax.swing.*;
import java.awt.*;
public class JFText extends JFrame{
public JFText(String title,int width,int height)
{
setTitle(title);
setSize(width,height);
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
setLocation((screenSize.width-width)/2,(screenSize.height-height)/2);
ImageIcon ii = new ImageIcon("java.jpg");
setIconImage(ii.getImage());
setBackground(Color.black);
setVisible(true);
}
public static void main(String[] args) {
// TODO, add your application code
JFrame.setDefaultLookAndFeelDecorated(true);
(new JFText("JFrame Test",400,300)).setDefaultCloseOperation(
JFrame.EXIT_ON_CLOSE);
}
}
[求助]JFrame中设置背景的问题?