There is a JTable
with DefaultTableModel
.
There is table's setforeground
, setbackground
and setselectioncolor
methods. Also when you are editing the cell you have table.setDefaultEditor(Object.class, new DefaultCellEditor(field))
method to change the editing cell's font color.
Now how to change the border color of the editing cell.
Thankyou.`
Asked
Active
Viewed 836 times
0

Sastrija
- 3,284
- 6
- 47
- 64

Usman Ahmed
- 79
- 2
- 3
- 11
-
what's wrong with textField.setBorder(...)? – kleopatra Feb 13 '12 at 09:05
1 Answers
4
You can use any of the following keys in UIManager.put()
to affect the corresponding Border
:
- Table.focusCellHighlightBorder
- Table.scrollPaneBorder
- TableHeader.cellBorder
For example:
UIManager.put("Table.focusCellHighlightBorder",
new BorderUIResource(BorderFactory.createLineBorder(Color.red)));
You can also change the color in your custom renderer/editor; PositiveIntegerCellEditor
is an example. See also Concepts: Editors and Renderers.
-
+1 nice summary :-) the problem here is as simple as not being able to go the step from field.setForeground (in the previous question) to field.setBorder – kleopatra Feb 13 '12 at 09:08
-
Thank you! I had missed the connection to this previous, related [Q&A](http://stackoverflow.com/q/9224365/230513). Cross-referencing. – trashgod Feb 13 '12 at 11:36