@Override
public void actionPerformed(final ActionEvent e) {
if(!JTextPanePreparer.this.popupMenu.isVisible()){
JTextPanePreparer.this.textPane.getInputMap().clear();
// this is the dirty way to pass "enter" to the JTextPane!
Toolkit.getDefaultToolkit().getSystemEventQueue().postEvent(new KeyEvent(
JTextPanePreparer.this.textPane,
KeyEvent.KEY_PRESSED,
System.currentTimeMillis(),
0,
KeyEvent.VK_ENTER,
KeyEvent.CHAR_UNDEFINED));
return;
}
if (JTextPanePreparer.this.jl.getSelectedValue() == null) {
JTextPanePreparer.this.popupMenu.setVisible(false);
} else {
JTextPanePreparer.this.insertSelectedWord();
JTextPanePreparer.this.popupMenu.setVisible(false);
}
}
});
this.textPane.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_TAB, 0), "myTab");
this.textPane.getActionMap().put("myTab", new AbstractAction() {
@Override
public void actionPerformed(final ActionEvent e) {
JTextPanePreparer.this.insertSelectedWord();
JTextPanePreparer.this.popupMenu.setVisible(false);
}
});
this.textPane.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_UP, 0), "myUp");
this.textPane.getActionMap().put("myUp", new AbstractAction() {
@Override
public void actionPerformed(final ActionEvent e) {
if(!JTextPanePreparer.this.popupMenu.isVisible()){
JTextPanePreparer.this.textPane.getInputMap().clear();
// this is the dirty way to pass "up" to the JTextPane!
Toolkit.getDefaultToolkit().getSystemEventQueue().postEvent(new KeyEvent(
JTextPanePreparer.this.textPane,
KeyEvent.KEY_PRESSED,
System.currentTimeMillis(),
0,
KeyEvent.VK_UP,
KeyEvent.CHAR_UNDEFINED));
return;
}
JTextPanePreparer.this.previousListItem();
}
});
this.textPane.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, 0), "myDown");
this.textPane.getActionMap().put("myDown", new AbstractAction() {
@Override
public void actionPerformed(final ActionEvent e) {
if(!JTextPanePreparer.this.popupMenu.isVisible()){
JTextPanePreparer.this.textPane.getInputMap().clear();
// this is the dirty way to pass "down" to the JTextPane!
Toolkit.getDefaultToolkit().getSystemEventQueue().postEvent(new KeyEvent(
JTextPanePreparer.this.textPane,
KeyEvent.KEY_PRESSED,
System.currentTimeMillis(),
0,
KeyEvent.VK_DOWN,