Nimbus and Opacity
This one tripped me up, and I thought I'd post it here. I have a case where I need to pour text into a JTextField, but have that JTextField look like a JLabel. So as I type in one field, I need this "gray" second field to update, live, before the user's eyes. I also need the ability for the user to cut-and-paste values out of it. This sort of thing is reasonably common in properties panels and the like.
Now, normally all you have to do is something like this:
final JTextComponent previewComponent = new JTextField();
...and you have what looks like a JLabel but what behaves like a JTextField.
Well, except under Nimbus, where the setOpaque(false) seems to have no effect. Turns out you need to also set the background color to a transparent color as well. Fortunately, this combination of behaviors seems to work under all the other look and feels (looks and feels?):
previewComponent.setBackground(new Color(0, 0, 0, 0));
I hope this helps other Swing folks out.