Urgent, Howto Modify MouseEvent and add CTRL_MASK modifier?
Urgent, Howto Modify MouseEvent and add CTRL_MASK modifier?
I have a JTable, which I have setSelectionMode( ListSelectionModel.MULTIPLE_INTERVAL_SELECTION )
I need a way of Simulating a CTRL key pressed when a left MouseButton clicked is triggered. I need to control this with program logic, since the user won't be using a keyboard, and not a mouse,
but a Pen(pencil,styluspen) on a touch screen.
I was thinking of somehow using a MouseListener, then checking the event, and somehow adding the CTRL modifier and dispatchin the same event again or something like that.
Anybody that can help me out with this?
Kind Regards
Roger
[678 byte] By [
Eruditea] at [2007-11-26 15:22:38]

# 1
Anobody has a clue on this ?
Lets rephrase the question then.
I need a way to be able to make multiple selections in a JTable with a single mouse normal left button mouse click.
I know that you can do this with the help of a keyboard, holding down shif or ctrl keys, but my application users won't be using the keyboard.
Can this be achived ?
Kind Regards
Roger
# 2
You can write next code to explore selection handling system of JTable:
private JTable jt = new JTable(new DefaultTableModel(new String[][] {{"1", "2"}, {"3", "5"}}, new Object[] {"a", "b"})) {
public void valueChanged(ListSelectionEvent e) {
super.valueChanged(e);
new Exception().printStackTrace();
}
};
On Java 1.5.0.9: most important rows are:
javax.swing.plaf.basic.BasicTableUI$Handler.makeSelectionChange(BasicTableUI.java:1012)
and
at javax.swing.JTable.changeSelection(JTable.java:1680)
So, I think that you can find a few ways to resolve your problem.