Re: ListSelectionModel problem
- From: "danharrisandrews@xxxxxxxxx" <danharrisandrews@xxxxxxxxx>
- Date: 22 Sep 2006 11:51:20 -0700
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
- - - - - - - - - - - - - - - - - - - - - - - - -
.
- Follow-Ups:
- Re: ListSelectionModel problem
- From: Deniz Dogan
- Re: ListSelectionModel problem
- References:
- ListSelectionModel problem
- From: Deniz Dogan
- ListSelectionModel problem
- Prev by Date: Re: GridBagLayout problems
- Next by Date: How to grab the current look and feel's icon for a combobox button?
- Previous by thread: Re: ListSelectionModel problem
- Next by thread: Re: ListSelectionModel problem
- Index(es):