2

I am trying to create a simple button which should look like this-

enter image description here

JButton connectBtn = new JButton("Connect");
        Color blue = new Color(77,176,230);    
        connectBtn.setBackground(blue);

But the problem is the background blue color is not as dark as it should look.

I have tried all the below possibilities,but of no use:-(

connectBtn.setBackground(Color.blue);

connectBtn.setBackground(Color.BLUE.brighter());

connectBtn.setBackground(Color.decode("#0099cc"));//i tried simply #0099cc just to get any dark background

Kindly help me in setting this color to JButton background. Thanks.

user1071096
  • 155
  • 1
  • 3
  • 14
  • 1
    Printscreen -> Paint -> Colorpicker tells me that the color of the button is `1691d9` (or `22,145,217`), if that helps. – Keppil Oct 31 '12 at 14:36
  • @Keppil AFAIU - that is effectively 'the answer', though I disagree with the OP that it is a 'very dark blue' in the image. – Andrew Thompson Oct 31 '12 at 14:40

2 Answers2

2

PrintScreen -> Paint -> Colorpicker tells me that the color of your button is

1691D9  

or

(22,145,217)
Keppil
  • 45,603
  • 8
  • 97
  • 119
  • Thanks for the reply.Actually I already tried the same RGB value .But it looks lighter. But same color if I set it to the text on the Connect button,it looks darker.Not only this any color which looks darker on paint doesn;t look same on JButton:-( – user1071096 Oct 31 '12 at 15:16
2

Zoom shows that your button is painted with a gradient that includes several shades of blue, as well as anti-aliased text. You'll probably need a suitable ButtonUI, as shown here using GradientPaint. Note the use of RenderingHints to suggest aliasing settings.

Community
  • 1
  • 1
trashgod
  • 203,806
  • 29
  • 246
  • 1,045