JButton Hellp [英] JButton Hellp
问题描述
所以我想设置Jbutton的背景颜色。我知道做这种事情的正常方法是以下方式:
JButton button = new JButton(" xxxx");
button .setBackground(Color.RED);
但在我的程序中我按以下方式添加我的Jbutton ..
horizontalBox2 = Box.createHorizontalBox ();
horizontalBox2.add(新JButton(黑色));
所以如何设置此按钮的背景颜色说黑...任何帮助,将不胜感激。谢谢。
So I want to set the background color of a Jbutton. I know that the normal way to do such a thing is down the following way:
JButton button = new JButton("xxxx");
button.setBackground(Color.RED);
but in my program i add my Jbutton the following way..
horizontalBox2=Box.createHorizontalBox();
horizontalBox2.add(new JButton("Black"));
so how would i go about setting the background color of this button to say black??? Any help would be appreciated. Thanks.
推荐答案
@ yeshello54
这只是编程:您需要亲自引用该按钮,以便您可以设置其背景颜色:
@yeshello54
That is just programming: you need to have a reference to that button yourself so you can set its background colour:
请使用这些代码标签。文字是这样的:
[代码]
你的文字在这里...
[/ code]
将显示如下:
And please do use those code tags. Text like this:
[code]
your text here ...
[/code]
will display like this:
@JASAH
实际上这就是他所说的。还有另外一种方法:
@JosAH
Actually that was what he was telling. There is another way though:
这篇关于JButton Hellp的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!