• Post Reply Bookmark Topic Watch Topic
  • New Topic

JTextField background color and UIManager  RSS feed

 
Rachel Swailes
Ranch Hand
Posts: 434
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi there

I have a JPanel and on it is a JTextField. Now I want to set the color of the JTextField to be the same as that of the JPanel.

So I try this...

The color is no longer white, but the color is not the same as the JPanel.

Is there anything else that I could try?

Cheers,
Rachel
 
Pat Hays
Ranch Hand
Posts: 138
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here is simplest way to make it to be the same as the JPanel.

-----------
jTextField1.setOpaque(false);
 
Rachel Swailes
Ranch Hand
Posts: 434
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I tried that, but the field just stays white. And with the setBackground before it, it's that not quite panel color.
 
Don Kiddick
Ranch Hand
Posts: 580
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
attachField.setBackground(panel.getBackground());


?
 
Rachel Swailes
Ranch Hand
Posts: 434
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I tried that also, but the color is just not the same.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!