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; private JPanel myToolWindowContent;
public MyToolWindow(ToolWindow toolWindow) { public MyToolWindow(ToolWindow toolWindow) {
hideToolWindowButton.addActionListener(new ActionListener() { hideToolWindowButton.addActionListener(e -> toolWindow.hide(null));
public void actionPerformed(ActionEvent e) { refreshToolWindowButton.addActionListener(e -> currentDateTime());
toolWindow.hide(null);
}
});
refreshToolWindowButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
currentDateTime();
}
});
this.currentDateTime(); this.currentDateTime();
} }