English 中文(简体)
如何改变 Java小组的背景图?
原标题:How to change the background color on a Java panel?

现在,我获得的背景是灰色的。 我想将其改为黑色。 我尝试做一些事情,例如打井(color.BLACK);但我还是忙着工作。 任何建议?

public test() 
{
    setTitle("Adjustment Form");
    setSize(670,450);
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    setLocationRelativeTo(null);

    setLayout(new GridLayout(4,6,2,2));
    setVisible(true);   
}
最佳回答

你可以呼吁:


getContentPane().setBackground(Color.black);

或者在JFrame中增加使用JPanel。 然后,在联合小组中增加贵部分。 这将使你能够打电话。


setBackground(Color.black);

摘自JPanel造本。

问题回答

I think what he is trying to say is to use the getContentPane().setBackground(Color.the_Color_you_want_here)

but if u want to set the color to any other then the JFrame, you use the object.setBackground(Color.the_Color_you_want_here)

例如:

jPanel.setbackground(Color.BLUE)

<代码>Background() 是正确的使用方法。 在你改变之后,你是否重新pa? 如果在你面前改变,小组(或包含小组的架构)就应当发挥作用。

我假定我们正在处理一个联合阵线? 内容提要中的可见部分——必须使用jframe.getContentPane(......);





相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签