[英]How to change the caret color in a JTable
我正在創建一個 jTable 是否可以添加帶有可修改文本的新行,當我選擇要重寫的行時,插入符號顏色太淺了,我看不到它,所以我不知道我在哪里寫. 如何更改插入符號的顏色?
您可以做的是獲取單元格的編輯器組件,如果它是 JTextComponent 的子類,請調用JTextComponent.setCaretColor
。 默認情況下,JTable 的編輯器是 JTextComponent 的實例。
例子:
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;
}
};
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.