I have a JTABLE with three columns. First column is textfield, the Second and third is JTextarea.. Using tab key I can navigate from one cell to another. While navigating from Jtextfield column to JTextarea column , The JTextarea is not highlighted, how to set a color for JTextarea when it get focused , so I can easily find which column has the focus.. How I will set that color.? Please give some suggestions..
Thanks in Advance Vishwa
Create a Color
object and invoke the setBackground(Color)
method on your JTextArea, after checking if it has focus using the hasFocus()
.
For example:
JTextArea area = new JTextArea();
Color c = Color.CYAN;
if(area.hasFocus())
{
area.setBackground(c);
}
Don't forget to save the original color of the (accessible by calling area.getBackground()
) before you change it, and to set it back to this when it loses focus.