简体   繁体   中英

How to set “ very dark blue ” background color to the JButton?

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

在此处输入图片说明

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.

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

1691D9  

or

(22,145,217)

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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