![]() |
The Java Developers Almanac 1.4 |
|
e943. Disabling Selections in a JTable ComponentThe only way to completely prevent a selection in aJTable
component is to prevent it from getting the focus using
setFocusable(false). However, if you still need keystrokes to
work in the component, this method is not an option.
The next closest way to disable selections is to call
int rows = 10;
int cols = 5;
JTable table = new JTable(rows, cols);
// Do this only if there's no need for the component to have the focus
table.setFocusable(false);
// Partially disables selections (see description above)
table.setCellSelectionEnabled(false);
e940. Enabling Single or Multiple Selections in a JTable Component e941. Programmatically Making Selections in a JTable Component e942. Getting the Selected Cells in a JTable Component e944. Getting the Anchor Cell in a JTable Component
© 2002 Addison-Wesley. |