i try to set Background color of jbutton, but doesn't work? Look at image. Why doesnt work? How to fix?
I want red background :-)
save_button.setForeground(Color.red);
save_button.setBackground(Color.red);
close_button.setForeground(Color.red);
close_button.setBackground(Color.red);
Add to the code for both buttons :
save_button.setOpaque(true);
It should work, if not try disabling the border color
Related
I'm creating an AbstractColorChooserPanel for recent colours (in a 4 * 4 grid) and while setting the background colour for the recent colours it only appears as a border to the button instead of filling it.
According to this the code below should work:
button.setBackground(Color.RED);
button.setOpaque(true);
Ive also tried adding
button.setBorderPainted(false);
but all that displays is a grey (standard colour) button with a red border.
I have tried putting the code on a button outside the JColorChooser and received the same effect. example
How do I make it so the entire button is filled with the red colour instead of just the border?
EDIT: The problem turned out to be the UIManager (default system look and feel)
To solve this I modified the code used in this solution.
Try adding this :
button.setContentAreaFilled( false );
I'm trying to change the color of the default blue-gray border on my JTabbedPane. You can see the border circled in the image below.
I want to make this a dark gray color. I've tried using the following UIManager properties (which result in the UI in the image above):
UIManager.put("TabbedPane.background", Color.decode(Colors.FACE_BG));
UIManager.put("TabbedPane.foreground", Color.decode(Colors.FONT_WHITE));
UIManager.put("TabbedPane.opaque", true);
UIManager.put("TabbedPane.selected", Color.decode(Colors.TABLE_SELECTION));
UIManager.put("TabbedPane.border", BorderFactory.createLineBorder(Color.decode(Colors.DARK_GRAY), 1));
How do I achieve this? Thanks!
Try
nameOfYourComponent.setBorder(BorderFactory.createLineBorder(Color.black, 1));
// the second argument is thickness
Thank you for your kind, we learned from you many times.
I have xJButton class inherits JButton class.
I am doing this to add an image as icon and change it after it clicked.
I do not want the blue color to be as background and also i don't want any border on it.
Everything is working vine, except the border.
You can see there is 2 borders
setOpaque(false);
setContentAreaFilled(false);
setBackground(null);
can you help me?
You should be able to do it like this:
xJButton.setBorder(null);
xJButton.setBorderPainted(false);
xJButton.setContentAreaFilled(false);
xJButton.setOpaque(false);
How might I go about changing the color of a JOptionPane's border?
Here is a screenshot of the border I am talking about:
That blue border is what I am trying to get rid of.
I tried to set UIManager.put("OptionPane.border", new BorderFactory...)for LookAndFeel but that changed the inside border, not the outermost one.
I need to get rid of that blue border.
Any ideas?
-Mark
Read the JOptionPane API. It shows you how to create a JOption pane manually so that you have access to the JDialog. Once you have the JDialog you can remove the Border the same way you did in your last question:
Undecorated JDialog border
I have research on it these days, finally I found this code may help you!
UIManager.put("RootPane.frameBorder", new LineBorder(Color.red));
UIManager.put("RootPane.dialogBorder", new LineBorder(Color.red));
UIManager.put("RootPane.errorDialogBorder", new LineBorder(Color.red));
In LaF section there is the initialization of ShadowPopupBorder which used for tooltips, popups, and modal dialogs borders. So check if it is used around your software
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.