SlideShare a Scribd company logo
1 of 2
Download to read offline
Modify the code below so that two separate listener classes are used - one for each of the two
buttons. public class LettRight Panel extends JPanel {private JButton left, right; private JLabel
label; public LeftRightPanel () {left = new JButton ("Left"); right = new JButton ("Right");
label = new JLabel("Left/Right"); ButtonListener listener = new ButtonListener();
left.addActionListener (listener); right.addActionLiatener (listener); add (left); add (right); add
(label);} private class ButtonListener implements ActionListener public void actionPerformed
(ActionEvent event) {if (event.getSource() == left) label.setText("Left"); else
label.setText("Right");}}}
Solution
Hi,
I have modifief the code and highlighted the code changes below.
LeftRightPanel.java
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;
public class LeftRightPanel extends JPanel{
private JButton left, right;
private JLabel label;
public LeftRightPanel(){
left = new JButton("Left");
right = new JButton("Right");
label = new JLabel("Left/Right");
LeftButtonListener leftListener = new LeftButtonListener();
RightButtonListener rightListener = new RightButtonListener();
left.addActionListener(leftListener);
right.addActionListener(rightListener);
add(left);
add(right);
add(label);
}
private class LeftButtonListener implements ActionListener{
public void actionPerformed(ActionEvent e) {
label.setText("Left");
}
}
private class RightButtonListener implements ActionListener{
public void actionPerformed(ActionEvent e) {
label.setText("Right");
}
}
}

More Related Content

More from kostikjaylonshaewe47

There are two large plants in the authors’ yard a yucca tree and an.pdf
There are two large plants in the authors’ yard a yucca tree and an.pdfThere are two large plants in the authors’ yard a yucca tree and an.pdf
There are two large plants in the authors’ yard a yucca tree and an.pdfkostikjaylonshaewe47
 
The seaport town of New Monopoly has become extremely popular with sh.pdf
The seaport town of New Monopoly has become extremely popular with sh.pdfThe seaport town of New Monopoly has become extremely popular with sh.pdf
The seaport town of New Monopoly has become extremely popular with sh.pdfkostikjaylonshaewe47
 
The figure below shows a series of SNP loci (A-O) loci for two strai.pdf
The figure below shows a series of SNP loci (A-O) loci for two strai.pdfThe figure below shows a series of SNP loci (A-O) loci for two strai.pdf
The figure below shows a series of SNP loci (A-O) loci for two strai.pdfkostikjaylonshaewe47
 
The climatic stability hypothesis for the change in biodiversity with.pdf
The climatic stability hypothesis for the change in biodiversity with.pdfThe climatic stability hypothesis for the change in biodiversity with.pdf
The climatic stability hypothesis for the change in biodiversity with.pdfkostikjaylonshaewe47
 
Table 14.2 Primitive and Advanced Features of Nonvascular Plants as T.pdf
Table 14.2 Primitive and Advanced Features of Nonvascular Plants as T.pdfTable 14.2 Primitive and Advanced Features of Nonvascular Plants as T.pdf
Table 14.2 Primitive and Advanced Features of Nonvascular Plants as T.pdfkostikjaylonshaewe47
 
Solar energy is channeled by molecular vibration from... to the ..pdf
Solar energy is channeled by molecular vibration from... to the ..pdfSolar energy is channeled by molecular vibration from... to the ..pdf
Solar energy is channeled by molecular vibration from... to the ..pdfkostikjaylonshaewe47
 
report “Rabbits and Wolves”Discuss the changes in parameters and how.pdf
report “Rabbits and Wolves”Discuss the changes in parameters and how.pdfreport “Rabbits and Wolves”Discuss the changes in parameters and how.pdf
report “Rabbits and Wolves”Discuss the changes in parameters and how.pdfkostikjaylonshaewe47
 
prove thisSolutionSuppose that A is a product of element.pdf
prove thisSolutionSuppose that A is a product of element.pdfprove thisSolutionSuppose that A is a product of element.pdf
prove thisSolutionSuppose that A is a product of element.pdfkostikjaylonshaewe47
 
Our task this week is to diagnose patients who come in with various .pdf
Our task this week is to diagnose patients who come in with various .pdfOur task this week is to diagnose patients who come in with various .pdf
Our task this week is to diagnose patients who come in with various .pdfkostikjaylonshaewe47
 
number of lines should be included in the last page of the paper aft.pdf
number of lines should be included in the last page of the paper aft.pdfnumber of lines should be included in the last page of the paper aft.pdf
number of lines should be included in the last page of the paper aft.pdfkostikjaylonshaewe47
 
Lie detector tests are notoriously flawed. Assume that a particular .pdf
Lie detector tests are notoriously flawed.  Assume that a particular .pdfLie detector tests are notoriously flawed.  Assume that a particular .pdf
Lie detector tests are notoriously flawed. Assume that a particular .pdfkostikjaylonshaewe47
 
Imagine you have 3 identical siblings. You are all from the same pare.pdf
Imagine you have 3 identical siblings. You are all from the same pare.pdfImagine you have 3 identical siblings. You are all from the same pare.pdf
Imagine you have 3 identical siblings. You are all from the same pare.pdfkostikjaylonshaewe47
 
Implement a queue using a linkedlist (java)SolutionLinkedQueue.pdf
Implement a queue using a linkedlist (java)SolutionLinkedQueue.pdfImplement a queue using a linkedlist (java)SolutionLinkedQueue.pdf
Implement a queue using a linkedlist (java)SolutionLinkedQueue.pdfkostikjaylonshaewe47
 
I need help making a recursive Koch snowflake. Im using python. I ne.pdf
I need help making a recursive Koch snowflake. Im using python. I ne.pdfI need help making a recursive Koch snowflake. Im using python. I ne.pdf
I need help making a recursive Koch snowflake. Im using python. I ne.pdfkostikjaylonshaewe47
 
First, describe what a force is and what effects forces have on obje.pdf
First, describe what a force is and what effects forces have on obje.pdfFirst, describe what a force is and what effects forces have on obje.pdf
First, describe what a force is and what effects forces have on obje.pdfkostikjaylonshaewe47
 
Drag each label to the cell type it describes. Produce proteins and l.pdf
Drag each label to the cell type it describes. Produce proteins and l.pdfDrag each label to the cell type it describes. Produce proteins and l.pdf
Drag each label to the cell type it describes. Produce proteins and l.pdfkostikjaylonshaewe47
 
Discuss the role of proteins in membrane structure and transport of .pdf
Discuss the role of proteins in membrane structure and transport of .pdfDiscuss the role of proteins in membrane structure and transport of .pdf
Discuss the role of proteins in membrane structure and transport of .pdfkostikjaylonshaewe47
 
Chrome File Edit View History Bookmarks People Window Help my.unce.e.pdf
Chrome File Edit View History Bookmarks People Window Help  my.unce.e.pdfChrome File Edit View History Bookmarks People Window Help  my.unce.e.pdf
Chrome File Edit View History Bookmarks People Window Help my.unce.e.pdfkostikjaylonshaewe47
 
CASE STUDY There is a new phenomenon in the cybersecurity domain ca.pdf
CASE STUDY There is a new phenomenon in the cybersecurity domain ca.pdfCASE STUDY There is a new phenomenon in the cybersecurity domain ca.pdf
CASE STUDY There is a new phenomenon in the cybersecurity domain ca.pdfkostikjaylonshaewe47
 
Ben and Jerrys Homemade This case examines issues of asset contro.pdf
Ben and Jerrys Homemade This case examines issues of asset contro.pdfBen and Jerrys Homemade This case examines issues of asset contro.pdf
Ben and Jerrys Homemade This case examines issues of asset contro.pdfkostikjaylonshaewe47
 

More from kostikjaylonshaewe47 (20)

There are two large plants in the authors’ yard a yucca tree and an.pdf
There are two large plants in the authors’ yard a yucca tree and an.pdfThere are two large plants in the authors’ yard a yucca tree and an.pdf
There are two large plants in the authors’ yard a yucca tree and an.pdf
 
The seaport town of New Monopoly has become extremely popular with sh.pdf
The seaport town of New Monopoly has become extremely popular with sh.pdfThe seaport town of New Monopoly has become extremely popular with sh.pdf
The seaport town of New Monopoly has become extremely popular with sh.pdf
 
The figure below shows a series of SNP loci (A-O) loci for two strai.pdf
The figure below shows a series of SNP loci (A-O) loci for two strai.pdfThe figure below shows a series of SNP loci (A-O) loci for two strai.pdf
The figure below shows a series of SNP loci (A-O) loci for two strai.pdf
 
The climatic stability hypothesis for the change in biodiversity with.pdf
The climatic stability hypothesis for the change in biodiversity with.pdfThe climatic stability hypothesis for the change in biodiversity with.pdf
The climatic stability hypothesis for the change in biodiversity with.pdf
 
Table 14.2 Primitive and Advanced Features of Nonvascular Plants as T.pdf
Table 14.2 Primitive and Advanced Features of Nonvascular Plants as T.pdfTable 14.2 Primitive and Advanced Features of Nonvascular Plants as T.pdf
Table 14.2 Primitive and Advanced Features of Nonvascular Plants as T.pdf
 
Solar energy is channeled by molecular vibration from... to the ..pdf
Solar energy is channeled by molecular vibration from... to the ..pdfSolar energy is channeled by molecular vibration from... to the ..pdf
Solar energy is channeled by molecular vibration from... to the ..pdf
 
report “Rabbits and Wolves”Discuss the changes in parameters and how.pdf
report “Rabbits and Wolves”Discuss the changes in parameters and how.pdfreport “Rabbits and Wolves”Discuss the changes in parameters and how.pdf
report “Rabbits and Wolves”Discuss the changes in parameters and how.pdf
 
prove thisSolutionSuppose that A is a product of element.pdf
prove thisSolutionSuppose that A is a product of element.pdfprove thisSolutionSuppose that A is a product of element.pdf
prove thisSolutionSuppose that A is a product of element.pdf
 
Our task this week is to diagnose patients who come in with various .pdf
Our task this week is to diagnose patients who come in with various .pdfOur task this week is to diagnose patients who come in with various .pdf
Our task this week is to diagnose patients who come in with various .pdf
 
number of lines should be included in the last page of the paper aft.pdf
number of lines should be included in the last page of the paper aft.pdfnumber of lines should be included in the last page of the paper aft.pdf
number of lines should be included in the last page of the paper aft.pdf
 
Lie detector tests are notoriously flawed. Assume that a particular .pdf
Lie detector tests are notoriously flawed.  Assume that a particular .pdfLie detector tests are notoriously flawed.  Assume that a particular .pdf
Lie detector tests are notoriously flawed. Assume that a particular .pdf
 
Imagine you have 3 identical siblings. You are all from the same pare.pdf
Imagine you have 3 identical siblings. You are all from the same pare.pdfImagine you have 3 identical siblings. You are all from the same pare.pdf
Imagine you have 3 identical siblings. You are all from the same pare.pdf
 
Implement a queue using a linkedlist (java)SolutionLinkedQueue.pdf
Implement a queue using a linkedlist (java)SolutionLinkedQueue.pdfImplement a queue using a linkedlist (java)SolutionLinkedQueue.pdf
Implement a queue using a linkedlist (java)SolutionLinkedQueue.pdf
 
I need help making a recursive Koch snowflake. Im using python. I ne.pdf
I need help making a recursive Koch snowflake. Im using python. I ne.pdfI need help making a recursive Koch snowflake. Im using python. I ne.pdf
I need help making a recursive Koch snowflake. Im using python. I ne.pdf
 
First, describe what a force is and what effects forces have on obje.pdf
First, describe what a force is and what effects forces have on obje.pdfFirst, describe what a force is and what effects forces have on obje.pdf
First, describe what a force is and what effects forces have on obje.pdf
 
Drag each label to the cell type it describes. Produce proteins and l.pdf
Drag each label to the cell type it describes. Produce proteins and l.pdfDrag each label to the cell type it describes. Produce proteins and l.pdf
Drag each label to the cell type it describes. Produce proteins and l.pdf
 
Discuss the role of proteins in membrane structure and transport of .pdf
Discuss the role of proteins in membrane structure and transport of .pdfDiscuss the role of proteins in membrane structure and transport of .pdf
Discuss the role of proteins in membrane structure and transport of .pdf
 
Chrome File Edit View History Bookmarks People Window Help my.unce.e.pdf
Chrome File Edit View History Bookmarks People Window Help  my.unce.e.pdfChrome File Edit View History Bookmarks People Window Help  my.unce.e.pdf
Chrome File Edit View History Bookmarks People Window Help my.unce.e.pdf
 
CASE STUDY There is a new phenomenon in the cybersecurity domain ca.pdf
CASE STUDY There is a new phenomenon in the cybersecurity domain ca.pdfCASE STUDY There is a new phenomenon in the cybersecurity domain ca.pdf
CASE STUDY There is a new phenomenon in the cybersecurity domain ca.pdf
 
Ben and Jerrys Homemade This case examines issues of asset contro.pdf
Ben and Jerrys Homemade This case examines issues of asset contro.pdfBen and Jerrys Homemade This case examines issues of asset contro.pdf
Ben and Jerrys Homemade This case examines issues of asset contro.pdf
 

Recently uploaded

Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - Englishneillewis46
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and ModificationsMJDuyan
 
Play hard learn harder: The Serious Business of Play
Play hard learn harder:  The Serious Business of PlayPlay hard learn harder:  The Serious Business of Play
Play hard learn harder: The Serious Business of PlayPooky Knightsmith
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSCeline George
 
FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024Elizabeth Walsh
 
Spellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPSSpellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPSAnaAcapella
 
How to Add a Tool Tip to a Field in Odoo 17
How to Add a Tool Tip to a Field in Odoo 17How to Add a Tool Tip to a Field in Odoo 17
How to Add a Tool Tip to a Field in Odoo 17Celine George
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17Celine George
 
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...Nguyen Thanh Tu Collection
 
Model Attribute _rec_name in the Odoo 17
Model Attribute _rec_name in the Odoo 17Model Attribute _rec_name in the Odoo 17
Model Attribute _rec_name in the Odoo 17Celine George
 
Wellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptxWellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptxJisc
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxRamakrishna Reddy Bijjam
 
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...EADTU
 
OSCM Unit 2_Operations Processes & Systems
OSCM Unit 2_Operations Processes & SystemsOSCM Unit 2_Operations Processes & Systems
OSCM Unit 2_Operations Processes & SystemsSandeep D Chaudhary
 
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptxOn_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptxPooja Bhuva
 
REMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptxREMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptxDr. Ravikiran H M Gowda
 
Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jisc
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxheathfieldcps1
 
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxHMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxmarlenawright1
 

Recently uploaded (20)

Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - English
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and Modifications
 
Play hard learn harder: The Serious Business of Play
Play hard learn harder:  The Serious Business of PlayPlay hard learn harder:  The Serious Business of Play
Play hard learn harder: The Serious Business of Play
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POS
 
FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024
 
Spellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPSSpellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPS
 
How to Add a Tool Tip to a Field in Odoo 17
How to Add a Tool Tip to a Field in Odoo 17How to Add a Tool Tip to a Field in Odoo 17
How to Add a Tool Tip to a Field in Odoo 17
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17
 
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
 
Model Attribute _rec_name in the Odoo 17
Model Attribute _rec_name in the Odoo 17Model Attribute _rec_name in the Odoo 17
Model Attribute _rec_name in the Odoo 17
 
Wellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptxWellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptx
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
 
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
 
OSCM Unit 2_Operations Processes & Systems
OSCM Unit 2_Operations Processes & SystemsOSCM Unit 2_Operations Processes & Systems
OSCM Unit 2_Operations Processes & Systems
 
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptxOn_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
 
Our Environment Class 10 Science Notes pdf
Our Environment Class 10 Science Notes pdfOur Environment Class 10 Science Notes pdf
Our Environment Class 10 Science Notes pdf
 
REMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptxREMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptx
 
Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
 
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxHMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
 

Modify the code below so that two separate listener classes are used .pdf

  • 1. Modify the code below so that two separate listener classes are used - one for each of the two buttons. public class LettRight Panel extends JPanel {private JButton left, right; private JLabel label; public LeftRightPanel () {left = new JButton ("Left"); right = new JButton ("Right"); label = new JLabel("Left/Right"); ButtonListener listener = new ButtonListener(); left.addActionListener (listener); right.addActionLiatener (listener); add (left); add (right); add (label);} private class ButtonListener implements ActionListener public void actionPerformed (ActionEvent event) {if (event.getSource() == left) label.setText("Left"); else label.setText("Right");}}} Solution Hi, I have modifief the code and highlighted the code changes below. LeftRightPanel.java import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.JButton; import javax.swing.JLabel; import javax.swing.JPanel; public class LeftRightPanel extends JPanel{ private JButton left, right; private JLabel label; public LeftRightPanel(){ left = new JButton("Left"); right = new JButton("Right"); label = new JLabel("Left/Right"); LeftButtonListener leftListener = new LeftButtonListener(); RightButtonListener rightListener = new RightButtonListener(); left.addActionListener(leftListener); right.addActionListener(rightListener); add(left); add(right); add(label); } private class LeftButtonListener implements ActionListener{
  • 2. public void actionPerformed(ActionEvent e) { label.setText("Left"); } } private class RightButtonListener implements ActionListener{ public void actionPerformed(ActionEvent e) { label.setText("Right"); } } }