【问题标题】:how to set a Color to an JFrame [duplicate]如何将颜色设置为 JFrame [重复]
【发布时间】:2021-05-24 03:01:03
【问题描述】:

粉红色不起作用!

//Frame

JFrame f = new JFrame("Tab");

f.setBounds(100, 100, 1000, 1000);

f.setVisible(true);

f.setLayout(null);

f.setBackground(Color.pink);

【问题讨论】:

  • 粉色和其他任何颜色

标签: java swing jframe background-color


【解决方案1】:

您需要改用内容面板。直接替换

f.getContentPane().setBackground(Color.pink);

而不是

f.setBackground(Color.pink);

【讨论】:

    猜你喜欢
    • 2010-11-08
    • 2013-04-22
    • 2013-12-13
    • 2020-10-12
    • 2013-08-12
    • 2011-08-31
    • 1970-01-01
    • 2012-03-21
    • 2015-11-16
    相关资源
    最近更新 更多