简体   繁体   English

Java Swing页眉和页脚背景色

[英]Java swing Header & Footer background color

在此处输入图片说明 Is there any way to set Header and Footer in Java Swing? 有什么方法可以在Java Swing中设置页眉和页脚?

Actually I am using theme in my application and I have set fixed background color for all panels. 实际上,我在应用程序中使用主题,并且为所有面板设置了固定的背景色。 But now the work is to set different background color of Header and Footer panel. 但是现在的工作是设置“页眉”和“页脚”面板的不同背景色。 Can you give me any suggestion? 你能给我什么建议吗?

Thanks in advance.. 提前致谢..

Header and Footer are probably just JPanel s, so you can do setBackground(Color.YELLOW) or such. Header和Footer可能只是JPanel ,因此可以执行setBackground(Color.YELLOW)或类似的操作。 As you probably have several header and footes (seeing those tabs), you could make a single class: 由于您可能有几个页眉和页脚(请参见这些选项卡),因此可以制作一个类:

public class HeaderOrFooter extends JPanel {
    private static final Color bg = new Color(0xFFFF66);
    public HeaderOrFooter() {
       setBackground(bg);
    }
}

You can even use a http://docs.oracle.com/javase/6/docs/api/java/awt/SystemColor.html (for theming), like SystemColor.info . 您甚至可以使用http://docs.oracle.com/javase/6/docs/api/java/awt/SystemColor.html (用于主题设置),例如SystemColor.info

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM