private void addShortcutBlinker() { getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW) .put(KeyStroke.getKeyStroke("ctrl B"), "Blink Function"); getActionMap() .put( "Blink Function", new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { if (ACTIVE_FUNCTION == null) return; setEnabled(false); final Color3f oldColor = ACTIVE_FUNCTION.getColor(); ACTIVE_FUNCTION.setColor(Colors.WHITE); Timer timer = new Timer( 300, new ActionListener() { @Override public void actionPerformed(ActionEvent e) { ACTIVE_FUNCTION.setColor(oldColor); setEnabled(true); } }); timer.setRepeats(false); timer.start(); } }); }
private void addShortcutDelete() { getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW) .put(KeyStroke.getKeyStroke("ctrl D"), "Delete Function"); getActionMap() .put( "Delete Function", new AbstractAction() { public void actionPerformed(ActionEvent e) { if (ACTIVE_FUNCTION == null) return; deletePlot(ACTIVE_FUNCTION); }; }); }