How to change background color of JTabbedPane?

Using TabComponentsDemo as an example, setBackgroundAt() seems to work: private void initTabComponent(int i) { pane.setTabComponentAt(i, new ButtonTabComponent(pane)); pane.setBackgroundAt(i, Color.getHSBColor((float)i/tabNumber, 1, 1)); } Addendum: As @camickr helpfully observed, the target component must be opaque. import java.awt.Color; import java.awt.Dimension; import java.awt.EventQueue; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JTabbedPane; /** @see http://stackoverflow.com/questions/8752037 */ public class TabColors extends … Read more

How to make an element’s background-color a little darker using CSS

Add a dark layer on the top of it using background-image. This method keeps your text visible in the same color while changing only the background. .button { display: inline-block; color:#fff; padding: 10px 20px; font-size: 20px; background-color:red; } .button:hover { background-image: linear-gradient(rgba(0, 0, 0, 0.4) 0 0); } <div class=”button”> some text </div> <div class=”button” … Read more

Get the background color of a button in android

Unfortunately I don’t know how to retrieve the actual color. It’s easy to get this as a Drawable Button button = (Button) findViewById(R.id.my_button); Drawable buttonBackground = button.getBackground(); If you know this is a color then you can try ColorDrawable buttonColor = (ColorDrawable) button.getBackground(); And if you’re on Android 3.0+ you can get out the resource … Read more

Background-color hex to JavaScript variable

try this out: var rgbString = “rgb(0, 70, 255)”; // get this in whatever way. var parts = rgbString.match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/); // parts now should be [“rgb(0, 70, 255”, “0”, “70”, “255”] delete (parts[0]); for (var i = 1; i <= 3; ++i) { parts[i] = parseInt(parts[i]).toString(16); if (parts[i].length == 1) parts[i] = ‘0’ + parts[i]; } … Read more

What is the difference between background and background-color

Premising that those are two distinct properties, in your specific example there’s no difference in the result, since background actually is a shorthand for background-color background-image background-position background-repeat background-attachment background-clip background-origin background-size Thus, besides the background-color, using the background shorthand you could also add one or more values without repeating any other background-* property more … Read more