Examlex

Solved

Rewrite the Following Code to Use a Lambda Expression for the Button

question 18

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


Definitions:

Black Fraternal Organization

A group or society formed by African Americans that provides social support, community service, and brotherhood or sisterhood among its members.

African Masonic Lodge

Fraternal organizations within the African American community, providing social networking, community service, and sometimes acting as a forum for political organizing.

African Methodist Episcopal Church

A historic black church established in the United States, part of the larger Methodist Episcopal tradition.

Segregated Seating Policy

A discriminatory practice of separating people in public places based on race, often found in theaters, transportation, and schools, mainly prior to the civil rights movements.

Related Questions