@@ -349,6 +349,29 @@ public void windowGainedFocus(WindowEvent e) {
349
349
350
350
// Enable window resizing (which allows for full screen button)
351
351
setResizable (true );
352
+
353
+ {
354
+ // Move Lines Keyboard Shortcut (Alt + Arrow Up/Down)
355
+ KeyStroke moveUpKeyStroke = KeyStroke .getKeyStroke (KeyEvent .VK_UP , InputEvent .ALT_DOWN_MASK );
356
+ final String MOVE_UP_ACTION_KEY = "moveLinesUp" ;
357
+ textarea .getInputMap (JComponent .WHEN_FOCUSED ).put (moveUpKeyStroke , MOVE_UP_ACTION_KEY );
358
+ textarea .getActionMap ().put (MOVE_UP_ACTION_KEY , new AbstractAction () {
359
+ @ Override
360
+ public void actionPerformed (ActionEvent e ) {
361
+ handleMoveLines (true );
362
+ }
363
+ });
364
+
365
+ KeyStroke moveDownKeyStroke = KeyStroke .getKeyStroke (KeyEvent .VK_DOWN , InputEvent .ALT_DOWN_MASK );
366
+ final String MOVE_DOWN_ACTION_KEY = "moveLinesDown" ;
367
+ textarea .getInputMap (JComponent .WHEN_FOCUSED ).put (moveDownKeyStroke , MOVE_DOWN_ACTION_KEY );
368
+ textarea .getActionMap ().put (MOVE_DOWN_ACTION_KEY , new AbstractAction () {
369
+ @ Override
370
+ public void actionPerformed (ActionEvent e ) {
371
+ handleMoveLines (false );
372
+ }
373
+ });
374
+ }
352
375
}
353
376
354
377
@@ -821,14 +844,6 @@ protected JMenu buildEditMenu() {
821
844
editMenuUpdatable .add (action );
822
845
menu .add (item );
823
846
824
- item = new JMenuItem ("Move Selected Lines Up" );
825
- item .setAccelerator (KeyStroke .getKeyStroke (KeyEvent .VK_UP , InputEvent .ALT_DOWN_MASK ));
826
- item .addActionListener (e -> handleMoveLines (true ));
827
-
828
- item = new JMenuItem ("Move Selected Lines Down" );
829
- item .setAccelerator (KeyStroke .getKeyStroke (KeyEvent .VK_DOWN , InputEvent .ALT_DOWN_MASK ));
830
- item .addActionListener (e -> handleMoveLines (false ));
831
-
832
847
833
848
// Update copy/cut state on selection/de-selection
834
849
menu .addMenuListener (new MenuListener () {
0 commit comments