我用java写的程序背景颜色怎么显示不出来,用了颜色还是像没有颜色,亲问各位大神指点
importjava.awt.*;importjavax.swing.*;publicclasszhang{/***@paramargs*/publicstaticvoi...
import java.awt.*;
import javax.swing.*;
public class zhang {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
JWindow win=new JWindow();
JLabel lb=new JLabel("欢迎进入java世界!",JLabel.CENTER);
lb.setForeground(Color.red);
lb.setFont(new Font("楷体",Font.ITALIC+Font.BOLD,20));
JPanel pn=new JPanel();
pn.setBackground(Color.green);
win.getContentPane().add(lb);
win.setLocation(400,100);
win.setSize(500, 550);
win.setVisible(true);
win.toFront();
}
} 展开
import javax.swing.*;
public class zhang {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
JWindow win=new JWindow();
JLabel lb=new JLabel("欢迎进入java世界!",JLabel.CENTER);
lb.setForeground(Color.red);
lb.setFont(new Font("楷体",Font.ITALIC+Font.BOLD,20));
JPanel pn=new JPanel();
pn.setBackground(Color.green);
win.getContentPane().add(lb);
win.setLocation(400,100);
win.setSize(500, 550);
win.setVisible(true);
win.toFront();
}
} 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |