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.
This commit is contained in:
JJ Brown 2019-02-23 12:08:10 -06:00 committed by GitHub
parent 3124f8674d
commit 0dca50d851

View File

@ -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();
}