How to set background color of a button in Java GUI?

Check out JButton documentation. Take special attention to setBackground and setForeground methods inherited from JComponent Something like: for(int i=1;iSetBackground(Color. BLACK); btn.

SetForeground(Color. GRAY); p3. Add(btn); }.

Check out JButton documentation. Take special attention to setBackground and setForeground methods inherited from JComponent. Something like: for(int i=1;iValueOf(i)); btn.

SetBackground(Color. BLACK); btn. SetForeground(Color.

GRAY); p3. Add(btn); }.

Use the setBackground method to set the background and setForeground to change the colour of your text. Note however, that putting grey text over a black background might make your text a bit tough to read.

You may or may not have to use setOpaque method to ensure that the colors show up by passing true to the method.

It seems that the setBackground() method doesn't work well on some platforms (I'm using Windows 7). I found this answer to this question helpful. However, I didn't entirely use it to solve my problem.

Instead, I decided it'd be much easier and almost as aesthetic to color a panel next to the button.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions