Re: ListSelectionModel problem



Deniz Dogan wrote:
Code follows:

public void keyPressed(KeyEvent e) {
[...]
//selmodel is the ListSelectionModel of the JTable.
//mod is the String representation of the modifier keys pressed.
//table is the JTable.
else if ((mod.equals("Shift") || mod.equals("Ctrl")) && e.getKeyCode()
== KeyEvent.VK_ENTER) {

Hi Deniz:

Try something like this (see below). Also google for "For example, the
appropriate way to check that SHIFT and BUTTON1" and check the javadocs
for getModifiersEx.

int shiftMask = InputEvent.SHIFT_DOWN_MASK;
int ctrlMask = InputEvent.CTRL_DOWN_MASK;
int selectedrow = table.getSelectedRow();
if (selectedrow != -1) {
if ((e.getModifiersEx() & (shiftMask | ctrlMask)) == shiftMask) {
System.out.println("Shift");
} else if ((e.getModifiersEx() & (shiftMask | ctrlMask)) ==
ctrlMask) {
System.out.println("Ctrl");
}
}

Cheers,

Dan Andrews
- - - - - - - - - - - - - - - - - - - - - - - - -
Ansir Development Limited http://www.ansir.ca
- - - - - - - - - - - - - - - - - - - - - - - - -

.