标签:swing
构造器中添加
setBackground(Color.WHITE);
重新画图中添加
@Override
protected void paintComponent(Graphics g) {
super.paintComponent(g);
// 转换画笔为2D
Graphics2D g2d = (Graphics2D) g;
// 设置画笔粗细
g2d.setStroke(new BasicStroke(5.0f));
// 设置画笔颜色
g2d.setColor(Color.GRAY);
// 设置画笔字体
g2d.setFont(new Font("宋体", Font.BOLD, 14));
}
Swing JPanel 设置画布背景及自己绘图,布布扣,bubuko.com
标签:swing
原文地址:http://blog.csdn.net/daixinmei/article/details/38520407