From 0dca50d851044ebae74a7bdeb32389f1999e31c2 Mon Sep 17 00:00:00 2001 From: JJ Brown Date: Sat, 23 Feb 2019 12:08:10 -0600 Subject: [PATCH] Removed boilerplate code from example with lambdas Given the advent of Java 8, anonymous classes for one-line commands are more visual distraction than they are helpful. I replaced the two used here as action listeners for buttons with equivalent lambdas. --- tool_window/src/myToolWindow/MyToolWindow.java | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/tool_window/src/myToolWindow/MyToolWindow.java b/tool_window/src/myToolWindow/MyToolWindow.java index c04df7a30..000754b4a 100644 --- a/tool_window/src/myToolWindow/MyToolWindow.java +++ b/tool_window/src/myToolWindow/MyToolWindow.java @@ -16,16 +16,8 @@ public class MyToolWindow { private JPanel myToolWindowContent; public MyToolWindow(ToolWindow toolWindow) { - hideToolWindowButton.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - toolWindow.hide(null); - } - }); - refreshToolWindowButton.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - currentDateTime(); - } - }); + hideToolWindowButton.addActionListener(e -> toolWindow.hide(null)); + refreshToolWindowButton.addActionListener(e -> currentDateTime()); this.currentDateTime(); }