I'm creating a jTable were I can add new rows with text that can be modified, when I selected the row I want to rewrite the caret color is so light I can't see it so I don't know where I am writing. How can I change the caret color?
What you could do is get the editor component of your cell(s) and if it's a subclass of JTextComponent, call JTextComponent.setCaretColor
. By default, editors for a JTable are instances of JTextComponent.
Example:
JTable yourTable = new JTable( ) {
public Component prepareEditor( TableCellEditor editor, int row, int column ) {
Component c = super.prepareEditor( editor, row, column );
if( c instanceof JTextComponent )
((JTextComponent) c).setCaretColor( Color.RED );
return c;
}
};
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.