I'm studying at the moment and I've been given the simple (I thought so) task. I have to make this piece of code to work (I can't modify it):
JButton b = new JButton("Myszą ciśnij"); b.addMouseListener ( (MousePressListener) e -> System.out.println("ok")); I believe MousePressListener should be FunctionalInterface but then, it can't extend MouseListener. Is there any way to work around this issue, or am I approaching it from bad side?
Foothat is not a functional interface, make an interfaceBarthat extendsFoothat has exactly one abstract method and add the@FunctionalInterfaceannotation toBar? IfBaris not a functional interface in Java's eyes it will not compile.