diff --git a/flatlaf-theme-editor/src/main/java/com/formdev/flatlaf/themeeditor/FlatThemeEditorPane.java b/flatlaf-theme-editor/src/main/java/com/formdev/flatlaf/themeeditor/FlatThemeEditorPane.java index fe16226d..8bc22b38 100644 --- a/flatlaf-theme-editor/src/main/java/com/formdev/flatlaf/themeeditor/FlatThemeEditorPane.java +++ b/flatlaf-theme-editor/src/main/java/com/formdev/flatlaf/themeeditor/FlatThemeEditorPane.java @@ -25,10 +25,13 @@ import java.io.IOException; import java.nio.charset.StandardCharsets; import java.util.List; import javax.swing.BorderFactory; +import javax.swing.InputMap; +import javax.swing.JComponent; import javax.swing.JFrame; import javax.swing.JLayer; import javax.swing.JOptionPane; import javax.swing.JPanel; +import javax.swing.KeyStroke; import javax.swing.SwingUtilities; import javax.swing.UIManager; import javax.swing.border.MatteBorder; @@ -104,6 +107,11 @@ class FlatThemeEditorPane scrollPane.setBorder( BorderFactory.createEmptyBorder() ); scrollPane.setLineNumbersEnabled( true ); + // map Ctrl+PageUp/Down to a not-existing action to avoid that the scrollpane catches them + InputMap inputMap = scrollPane.getInputMap( JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT ); + inputMap.put( KeyStroke.getKeyStroke( "ctrl PAGE_UP" ), "__dummy__" ); + inputMap.put( KeyStroke.getKeyStroke( "ctrl PAGE_DOWN" ), "__dummy__" ); + // create error strip errorStrip = new ErrorStrip( textArea ); diff --git a/flatlaf-theme-editor/src/main/java/com/formdev/flatlaf/themeeditor/FlatThemeFileEditor.java b/flatlaf-theme-editor/src/main/java/com/formdev/flatlaf/themeeditor/FlatThemeFileEditor.java index 62cc9b3d..37ac305d 100644 --- a/flatlaf-theme-editor/src/main/java/com/formdev/flatlaf/themeeditor/FlatThemeFileEditor.java +++ b/flatlaf-theme-editor/src/main/java/com/formdev/flatlaf/themeeditor/FlatThemeFileEditor.java @@ -327,23 +327,16 @@ public class FlatThemeFileEditor } private void nextEditor() { - if( tabbedPane.getTabCount() == 0 ) - return; - - int index = tabbedPane.getSelectedIndex() + 1; - if( index >= tabbedPane.getTabCount() ) - index = 0; - tabbedPane.setSelectedIndex( index ); + notifyTabbedPaneAction( tabbedPane.getActionMap().get( "navigatePageDown" ) ); } private void previousEditor() { - if( tabbedPane.getTabCount() == 0 ) - return; + notifyTabbedPaneAction( tabbedPane.getActionMap().get( "navigatePageUp" ) ); + } - int index = tabbedPane.getSelectedIndex() - 1; - if( index < 0 ) - index = tabbedPane.getTabCount() - 1; - tabbedPane.setSelectedIndex( index ); + private void notifyTabbedPaneAction( Action action ) { + if( action != null && action.isEnabled() ) + action.actionPerformed( new ActionEvent( tabbedPane, ActionEvent.ACTION_PERFORMED, null ) ); } private void find() { @@ -634,7 +627,7 @@ public class FlatThemeFileEditor //---- nextEditorMenuItem ---- nextEditorMenuItem.setText("Next Editor"); - nextEditorMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_TAB, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); + nextEditorMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_PAGE_DOWN, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); nextEditorMenuItem.setMnemonic('N'); nextEditorMenuItem.addActionListener(e -> nextEditor()); windowMenu.add(nextEditorMenuItem); @@ -642,7 +635,7 @@ public class FlatThemeFileEditor //---- previousEditorMenuItem ---- previousEditorMenuItem.setText("Previous Editor"); previousEditorMenuItem.setMnemonic('P'); - previousEditorMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_TAB, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()|KeyEvent.SHIFT_DOWN_MASK)); + previousEditorMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_PAGE_UP, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); previousEditorMenuItem.addActionListener(e -> previousEditor()); windowMenu.add(previousEditorMenuItem); } diff --git a/flatlaf-theme-editor/src/main/java/com/formdev/flatlaf/themeeditor/FlatThemeFileEditor.jfd b/flatlaf-theme-editor/src/main/java/com/formdev/flatlaf/themeeditor/FlatThemeFileEditor.jfd index 982f2848..41263891 100644 --- a/flatlaf-theme-editor/src/main/java/com/formdev/flatlaf/themeeditor/FlatThemeFileEditor.jfd +++ b/flatlaf-theme-editor/src/main/java/com/formdev/flatlaf/themeeditor/FlatThemeFileEditor.jfd @@ -145,7 +145,7 @@ new FormModel { add( new FormComponent( "javax.swing.JMenuItem" ) { name: "nextEditorMenuItem" "text": "Next Editor" - "accelerator": static javax.swing.KeyStroke getKeyStroke( 9, 4226, false ) + "accelerator": static javax.swing.KeyStroke getKeyStroke( 34, 4226, false ) "mnemonic": 78 addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "nextEditor", false ) ) } ) @@ -153,7 +153,7 @@ new FormModel { name: "previousEditorMenuItem" "text": "Previous Editor" "mnemonic": 80 - "accelerator": static javax.swing.KeyStroke getKeyStroke( 9, 4291, false ) + "accelerator": static javax.swing.KeyStroke getKeyStroke( 33, 4226, false ) addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "previousEditor", false ) ) } ) } )