wordstudent

Tool for learning meaning of words
git clone git://git.wimdupont.com/wordstudent.git
Log | Files | Refs | README | LICENSE

commit 3a363fcffb58b41ca7a5f43a04c190807835155d
parent b3751367d1c3c1567768d720f20d2a5d91637960
Author: Wim Dupont <wim@wimdupont.com>
Date:   Sat, 26 Aug 2023 14:42:49 +0200

update

Diffstat:
Msrc/main/java/com/wimdupont/service/WordTester.java | 24++++++++++++------------
1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/src/main/java/com/wimdupont/service/WordTester.java b/src/main/java/com/wimdupont/service/WordTester.java @@ -114,9 +114,9 @@ public class WordTester { dictionaryPanel.setForeground(new Color(150, 250, 250)); dictionaryPanel.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 15)); var actionMap = new ActionMap(); - actionMap.put(PREVIOUS, toActionListener(previous(index, wordField, words, dictionaryPanel))); - actionMap.put(SHOW, toActionListener(show(index, words, dictionaryPanel))); - actionMap.put(NEXT, toActionListener(next(index, wordField, words, dictionaryPanel))); + actionMap.put(PREVIOUS, previous(index, wordField, words, dictionaryPanel)); + actionMap.put(SHOW, show(index, words, dictionaryPanel)); + actionMap.put(NEXT, next(index, wordField, words, dictionaryPanel)); dictionaryPanel.setActionMap(actionMap); return dictionaryPanel; } @@ -140,30 +140,30 @@ public class WordTester { return btnPanel; } - private Runnable previous(AtomicInteger index, JLabel wordField, List<String> words, JTextArea showPanel) { - return () -> { + private AbstractAction previous(AtomicInteger index, JLabel wordField, List<String> words, JTextArea showPanel) { + return toActionListener(() -> { if (index.get() > 0) { wordField.setText(words.get(index.decrementAndGet())); showPanel.setText(null); } - }; + }); } - private Runnable show(AtomicInteger index, List<String> words, JTextArea showPanel) { - return () -> { + private AbstractAction show(AtomicInteger index, List<String> words, JTextArea showPanel) { + return toActionListener(() -> { var word = wordRepository.findByWord(words.get(index.get())); word.ifPresent(wordDto -> showPanel.setText(toMeaning(wordDto))); showPanel.setVisible(true); - }; + }); } - private Runnable next(AtomicInteger index, JLabel wordField, List<String> words, JTextArea showPanel) { - return () -> { + private AbstractAction next(AtomicInteger index, JLabel wordField, List<String> words, JTextArea showPanel) { + return toActionListener(() -> { if (index.get() < words.size()) { wordField.setText(words.get(index.incrementAndGet())); showPanel.setText(null); } - }; + }); } private AbstractAction toActionListener(Runnable runnable) {