Essay
Rewrite the following code to use a Lambda expression for the button action listener.
import java.util.ArrayList;
import javax.swing.JButton;
import javax.swing.JFrame;
import java.awt.Color;
import java.awt.Container;
import java.awt.FlowLayout;
public class ButtonDemo3 extends JFrame
{
public ButtonDemo3 )
{
setSize250,100);
setDefaultCloseOperationJFrame.EXIT_ON_CLOSE);
setTitle"Button Demo");
Container contentPane = getContentPane );
contentPane.setBackgroundColor.BLUE);
contentPane.setLayoutnew FlowLayout ));
JButton goButton = new JButton"Green");
goButton.addActionListener
{ e } - > contentPane.setBackgroundColor.GREEN));
contentPane.addgoButton);
}
public static void mainString[] args)
{
ButtonDemo3 buttonGui = new ButtonDemo3 );
buttonGui.setVisibletrue);
}
}
Correct Answer:

Verified
import java.util.ArrayList;
import javax...View Answer
Unlock this answer now
Get Access to more Verified Answers free of charge
Correct Answer:
Verified
import javax...
View Answer
Unlock this answer now
Get Access to more Verified Answers free of charge
Q13: What is a JavaBean?
Q14: A thread's start method invokes the thread's
Q15: The JavaFX scene graph:<br>A)Is used to plot
Q16: _ is an enhancement of simple accessor
Q17: If your class implements Runnable then what
Q19: SQL stands for Structured Query Language.
Q20: An InterruptedException is a checked exception.
Q21: _ refers to a framework that facilitates
Q22: An alternative to deriving a thread from
Q23: A server creates at least two sockets,one