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 javax...
View Answer
Unlock this answer now
Get Access to more Verified Answers free of charge
Q16: What is an advantage of applying Java
Q17: A thread's start method invokes the thread's
Q18: Threads execute in a _ fashion.
A)parallel
B)serial
C)complex
D)none of
Q19: When a server executes the accept)method it:
A)Blocks
Q20: Java's Thread class is in the _
Q21: What is a JavaBean?
Q22: What other programming technique can be combined
Q23: Discuss the components of the JavaBean model.
Q24: What are Enterprise JavaBeans?
Q25: What is a socket?
Unlock this Answer For Free Now!
View this answer and more for free by performing one of the following actions
Scan the QR code to install the App and get 2 free unlocks
Unlock quizzes for free by uploading documents