为了账号安全,请及时绑定邮箱和手机立即绑定

面板的背景颜色

面板的背景颜色

HUH函数 2022-10-12 10:53:06
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */package foodmeterproject;import java.awt.Color;/** * * @author al-sany */public class FoodMeterProject {    /**     * @param args the command line arguments     */    public static void main(String[] args) {        // TODO code application logic here        FirstFrame frame=new FirstFrame();        frame.setVisible(true);        frame.setBackground(Color.green);    }}我想改变我的程序背景。有一个JPanel。我想给它的背景上色。我用frame.setBackground(Color.green),但它不能改变背景。你们能帮帮我吗?提前致谢。
查看完整描述

1 回答

?
LEATH

TA贡献1936条经验 获得超6个赞

尝试这个

frame.getContentPane().setBackground(Color.GREEN);


查看完整回答
反对 回复 2022-10-12
  • 1 回答
  • 0 关注
  • 78 浏览

添加回答

举报

0/150
提交
取消
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号