Fixed bug where typing a '-' does not focus on the absolute value text box. This is necessary when inserting values into tables that contain negative values.

- now when focusing on the table and typing a '-' focus will switch to the absolute value box and the - will be inserted into that box.
This commit is contained in:
Scotthew 2012-06-21 16:31:58 -07:00
parent 9b3f92b7a4
commit f2cf7f587f
1 changed files with 10 additions and 0 deletions

View File

@ -283,6 +283,13 @@ public abstract class Table extends JPanel implements Serializable {
getFrame().getToolBar().multiply();
}
};
Action numNegAction = new AbstractAction() {
private static final long serialVersionUID = -6346750245035640773L;
public void actionPerformed(ActionEvent e) {
getFrame().getToolBar().focusSetValue('-');
}
};
// set input mapping
InputMap im = getInputMap(WHEN_IN_FOCUSED_WINDOW);
@ -314,6 +321,7 @@ public abstract class Table extends JPanel implements Serializable {
KeyStroke numPoint = KeyStroke.getKeyStroke('.');
KeyStroke copy = KeyStroke.getKeyStroke("control C");
KeyStroke paste = KeyStroke.getKeyStroke("control V");
KeyStroke numNeg = KeyStroke.getKeyStroke('-');
im.put(right, "right");
im.put(left, "left");
@ -342,6 +350,7 @@ public abstract class Table extends JPanel implements Serializable {
im.put(paste, "pasteAction");
im.put(mulKey, "mulAction");
im.put(mulKeys, "mulAction");
im.put(numNeg, "numNeg");
getActionMap().put(im.get(right), rightAction);
getActionMap().put(im.get(left), leftAction);
@ -370,6 +379,7 @@ public abstract class Table extends JPanel implements Serializable {
getActionMap().put(im.get(mulKeys), multiplyAction);
getActionMap().put(im.get(copy), copyAction);
getActionMap().put(im.get(paste), pasteAction);
getActionMap().put(im.get(numNeg), numNegAction);
this.setInputMap(WHEN_FOCUSED, im);
}