Change color of JTabbedPane border - java

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

Related

Java Swing TitledBorder Customizing Color

I'm stuck on something silly (it feels that way). I'm trying to create a Java TitledBorder with a specific Color for the border and the Title.
Border varBorder;
// this works (creates red border with black text)
varBorder = BorderFactory.createLineBorder(Color.RED);
varBorder = BorderFactory.createTitledBorder(lv_border, "Info");
// this crashes
varBorder.setTitleColor(Color.RED);
varBorder.setBorder(lv_border);
What is the correct way to set the color of a TitleBorder?
In your code varBorder is of Border type. You may cast it to TitledBorder or change the type of variable. In Border class there is no such method like setTitleColor.

JButton setBackground doesn't work

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

Color of JOptionPane border

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

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.

I wanna hide this little white-thing on the JTable

The picture shows a thin (1 pixel?) white margin (marked in blue) inside the border of a JTable.
How can the margin be eliminated, or the colour be changed?
I have tried:
Changing the JTable
Changing the ScrollPane
I set both to opaque without success.
Thanks for help.
The sides there are simply the border set by whatever JComponent its contained in. Remove the border (or change it to a line border for instance) and that style will go away. :)

Categories

Resources