Question: package edu.buffalostate.cis 4 2 5 . sp 2 4 . put - your - username - here; / * * * File: MeFirstPanel.java * *
package edu.buffalostate.cisspputyourusernamehere;
File: MeFirstPanel.java
Description: This class defines a GUI in a JPanel which contains
two JButton with initial labels Me first!" and Me next!".
Pressing either button causes the labels to be exchanged.
Requirements
Add a third button to the panel, with the label "third"
Every time any of the buttons are pressed, the labels
should shift one place to the right firstsecondthird
would shift to thirdfirstsecond when one of the buttons
was pressed
@author putyournamehere
import javax.swing.;
import java.awt.event.;
public class MeFirstPanel extends JPanel implements ActionListener
private JButton aButton;
private JButton bButton;
add button here
String aText "first";
String bText "second";
add string here
String tempText; To use to exchange labels
public MeFirstPanel
aButton new JButtonaText;
aButton.addActionListenerthis; add event handler
bButton new JButtonbText;
bButton.addActionListenerthis; add event handler
addaButton; add button to JPanel
addbButton; add button to JPanel
End MeFirstPanel
actionPerformed
@param e button clicked
public void actionPerformedActionEvent e
tempText aText; Exchange the strings
aText bText;
bText tempText;
add code here
aButton.setTextaText; Set button labels
bButton.setTextbText;
add code here
EndactionPeformed
End MeFirstPanel class
package edu.buffalostate.cisfaexercises.putyourlastnamehere;
File: MeFirstApp.java
Description: This app creates a MeFirstPanel and
adds it to the app's content pane.
Assignment: see MeFirstPanel.java
@author putyournamehere
import javax.swing.;
public class MeFirstApp extends JFrame
private static final long serialVersionUID L;
public MeFirstApp
setSize;
getContentPaneaddnew MeFirstPanel;
register 'Exit upon closing' as a default close operation
setDefaultCloseOperation EXITONCLOSE ;
End MeFirstApp
public static void mainString args
MeFirstApp b new MeFirstApp;
bsetVisibletrue;
End main
End MeFirstApp class
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
