Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Java Program Write a program that uses multiple layout managers, buttons, labels

ID: 3581670 • Letter: J

Question

Java Program

Write a program that uses multiple layout managers, buttons, labels, and text areas. It should have an appropriate title on the title bar.

You will have 5 buttons, one for each vowel and when the button is pressed it will display the text of the button in the area below.   ONLY 1 ACTION LISTENER IS ALLOWED in the program.

It should look similar to the program below:

Make sure all functionality is there.

  Have it spaced and lined up as shown above including margins.

Program Checklist

-Has 5 buttons, each labeled with a vowel

-Has a text field that displays letter of button pressed.

-Has one action listener that can handle all 5 buttons.

-It is laid out as shown in the sample, has margins around the fields.

E Buy a vowel You bought:

Explanation / Answer

public void init() {
  
setBackground(Color.Gray);
// grid layout used as all panel having same size

Pane box = new Pane();
box.setLayout(new GridLayout(1,5));

Button vow1 = new Button("a");
vow1.addActionListener(this); // Applet will listen for
box.add(vow1); // events from the buttons.

Button vow2 = new Button("e");
vow2.addActionListener(this);
box.add(vow2);

Button vow3 = new Button("i");
vow3.addActionListener(this);
box.add(vow3);

Button vow4 = new Button("o");
vow4.addActionListener(this);
box.add(vow4);

Button vow5 = new Button("u");
vow5.addActionListener(this);
box.add(vow5);
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote