mirror of
https://github.com/JFormDesigner/FlatLaf.git
synced 2025-12-07 22:40:53 +03:00
Theme Editor: find previous/next with UP/DOWN keys
This commit is contained in:
@@ -17,6 +17,9 @@
|
|||||||
package com.formdev.flatlaf.themeeditor;
|
package com.formdev.flatlaf.themeeditor;
|
||||||
|
|
||||||
import java.awt.Container;
|
import java.awt.Container;
|
||||||
|
import java.awt.event.ActionEvent;
|
||||||
|
import java.awt.event.KeyEvent;
|
||||||
|
import java.util.function.Consumer;
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
import javax.swing.event.DocumentEvent;
|
import javax.swing.event.DocumentEvent;
|
||||||
import javax.swing.event.DocumentListener;
|
import javax.swing.event.DocumentListener;
|
||||||
@@ -45,6 +48,14 @@ class FlatFindReplaceBar
|
|||||||
|
|
||||||
findField.getDocument().addDocumentListener( new MarkAllUpdater() );
|
findField.getDocument().addDocumentListener( new MarkAllUpdater() );
|
||||||
|
|
||||||
|
// find previous/next with UP/DOWN keys
|
||||||
|
InputMap inputMap = findField.getInputMap();
|
||||||
|
inputMap.put( KeyStroke.getKeyStroke( KeyEvent.VK_UP, 0 ), "findPrevious" );
|
||||||
|
inputMap.put( KeyStroke.getKeyStroke( KeyEvent.VK_DOWN, 0 ), "findNext" );
|
||||||
|
ActionMap actionMap = findField.getActionMap();
|
||||||
|
actionMap.put( "findPrevious", new ConsumerAction( e -> findPrevious() ) );
|
||||||
|
actionMap.put( "findNext", new ConsumerAction( e -> findNext() ) );
|
||||||
|
|
||||||
findPreviousButton.setIcon( new FlatSVGIcon( "com/formdev/flatlaf/themeeditor/icons/findAndShowPrevMatches.svg" ) );
|
findPreviousButton.setIcon( new FlatSVGIcon( "com/formdev/flatlaf/themeeditor/icons/findAndShowPrevMatches.svg" ) );
|
||||||
findNextButton.setIcon( new FlatSVGIcon( "com/formdev/flatlaf/themeeditor/icons/findAndShowNextMatches.svg" ) );
|
findNextButton.setIcon( new FlatSVGIcon( "com/formdev/flatlaf/themeeditor/icons/findAndShowNextMatches.svg" ) );
|
||||||
matchCaseToggleButton.setIcon( new FlatSVGIcon( "com/formdev/flatlaf/themeeditor/icons/matchCase.svg" ) );
|
matchCaseToggleButton.setIcon( new FlatSVGIcon( "com/formdev/flatlaf/themeeditor/icons/matchCase.svg" ) );
|
||||||
@@ -268,4 +279,21 @@ class FlatFindReplaceBar
|
|||||||
markAll();
|
markAll();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---- class ConsumerAction -----------------------------------------------
|
||||||
|
|
||||||
|
private static class ConsumerAction
|
||||||
|
extends AbstractAction
|
||||||
|
{
|
||||||
|
private final Consumer<ActionEvent> consumer;
|
||||||
|
|
||||||
|
ConsumerAction( Consumer<ActionEvent> consumer ) {
|
||||||
|
this.consumer = consumer;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void actionPerformed( ActionEvent e ) {
|
||||||
|
consumer.accept( e );
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user