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

Hello, I need some help with this java file. Add a GUI input screen to the Dinne

ID: 3712894 • Letter: H

Question

Hello,

I need some help with this java file.

Add a GUI input screen to the Dinner & A Movie application. The screen will input the guest names for your dinner out.

At least one guest name is required to move on in the application, and at most 4 guest names may be entered.

Once a guest name has been input, it should display on the Guest List.

Here is the few classes I have completed for this assignment in a rar file.

https://drive.google.com/file/d/17GqTmy7miFuQttjE5Fr01RO7U0QaTIJ_/view?usp=sharing

And this is what needs to be modify into the files

Do NOT use NetBeans or another Swing/GUI IDE for this. Please use a code editor to write the code manually.

Import classes from javax.swing and java.awt packages as needed. Only import the classes you use in your application.

Modify the DoubleDate class to extend the JFrame class.

Declare the following instance variables:

JPanel inputPanel

JPanel guestList

JLabel addGuestPrompt

JLabel guestListHeader

JTextField newGuestName

JButton addGuest

JButton letsGo

Modify the DoubleDate constructor to configure the GUI components.

Remove the parameters.

Remove the addition of names to the guests ArrayList. Names will now be added through the GUI.

Call the JFrame constructor by calling the super constructor and pass the title “Double Date” as a String argument.

Set the layout of the DoubleDate by calling the setLayout method, which is inherited from the JFrame class.

Set the layout to be a new GridLayout with 2 rows and 2 columns.

Instantiate addGuestPrompt with the text “Enter a guest name:”. Using the add method which DoubleDate inherits from JFrame, add addGuestPrompt to the JFrame layout.

Instantiate guestListHeader with the text “Guest List”. Using the add method which DoubleDate inherits from JFrame, add guestListHeader to the JFrame layout.

Instantiate inputPanel as a new JPanel. Set the layout of this JPanel to a new FlowLayout using its setLayout method.

Instantiate the JTextField object as a new JTextField with a size of 20.

Add the JTextField object to the inputPanel, using the add method of the inputPanel.

Instantiate the addGuest button as a new JButton with the text “Add Guest to List”. Add it to the inputPanel.

Instantiate the letsGo button as a new JButton with the text “Let’s Go Out!”. Add it to the inputPanel.

Set the visibility of the letsGo button to false. It should only become visible when there is at least one guest on the Guest List.

Add the inputPanel to the DoubleDate JFrame layout.

Instantiate the guestList as a new JPanel. Set its layout as a new FlowLayout, and add it to the DoubleDate JFrame layout.

Set the size and default close operation of the DoubleDate JFrame using the following lines of code:

setSize(500, 250);

The layout of the GUI is complete, however it will not appear or do anything yet.

Add new method to the DoubleDate class: public void goOnDate(DoubleDate date)

Copy everything from the existing main method into the goOnDate method, except for the declaration of the DoubleDate object (the declaration should stay in the main method).

Update the main method:

In the main method, there should be a declaration of a new DoubleDate object, and we will now make the DoubleDate GUI visible.

DoubleDate date = new DoubleDate();

date.setVisible(true);

Add the JFrame paint method:

public void paint( Graphics g ) {

super.paint( g );

Add Action Listeners

Each JButton needs an ActionListener to process button click events.

To learn both methods, one action listener will be implemented as a nested private class and the other action listener will be defined as an anonymous class.

private class AddGuestHandler implements ActionListenerpublic void actionPerformed(ActionEvent e)

Get the guest name using the getText() method of the newGuestName JTextField object.

Add the new guest name to the guests ArrayList.

Reset the value of the newGuestName JTextField to an empty String using the setText(“”) method.

Add a new JLabel to the guestList JPanel containing the new guest name.

Set the visibility of the letsGo JButton to true, as we now have at least one guest.

By passing a condition to the setVisible(boolean b) method of the addGuest JButton, set the visibility to true if there are less than 4 guests or false if there are 4 or more guests.

Use the ArrayList size() method to determine the number of guests.

Do NOT declare a boolean variable.

Because we have added new components to the guestList JPanel, we need to validate it.

Because the components of our JFrame have changed, it must be repainted. However, we can repaint the guestList JPanel alone, as it is the only piece that has changed. This is more optimal than repainting the entire JFrame.

Add a new instance of the AddGuestHandler class to the addGuest JButton using the addActionListener(ActionListener l) method.

For the letsGo JButton, we will define an anonymous class inside of the addActionListener(ActionListener l) method.

In the DoubleDate constructor, after the letsGo JButton is instantiated, add the following lines of code:

letsGo.addActionListener( new ActionListener() {

public void actionPerformed( ActionEvent e ) {

goOnDate((DoubleDate) SwingUtilities.getRoot(

(Component) e.getSource()));

} );

In the actionPerformed method:

The first line gets the root JFrame Component of the Component which was the source of the ActionEvent. In this case, that root Component happens to be the DoubleDate object, so we can cast it as such.

We then pass the root DoubleDate JFrame to the goOnDate method, which takes a DoubleDate object as a parameter.

Then we set the visibility of the JFrame to false, so it disappears from the screen.

Finally, we dispose of the JFrame object, removing it from memory and terminating the program.

Explanation / Answer

package com.movieapp;

import android.app.Application;

import android.util.Log;

import android.support.annotation.NonNull;

import com.facebook.react.ReactApplication;

import com.oblador.vectoricons.VectorIconsPackage;

import com.facebook.react.ReactInstanceManager;

import com.facebook.react.ReactNativeHost;

import com.facebook.react.ReactPackage;

import com.facebook.react.shell.MainReactPackage;

import com.reactnativenavigation.NavigationApplication;

import com.BV.LinearGradient.LinearGradientPackage;

import com.lugg.ReactNativeConfig.ReactNativeConfigPackage;

import com.facebook.soloader.SoLoader;

import java.util.Arrays;

import java.util.List;

public class MainApplication extends NavigationApplication {

// private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) {

// @Override

// public boolean getUseDeveloperSupport() {

// return BuildConfig.DEBUG;

// }

//

// @Override

// protected List<ReactPackage> getPackages() {

// return Arrays.<ReactPackage>asList(

// new MainReactPackage(),

// );

// }

// };

@Override

public boolean isDebug() {

return BuildConfig.DEBUG;

}

@NonNull

@Override

public List<ReactPackage> createAdditionalReactPackages() {

return Arrays.<ReactPackage>asList(

new VectorIconsPackage(),

new LinearGradientPackage(),

new ReactNativeConfigPackage()

);

}

@Override

public void onCreate() {

super.onCreate();

SoLoader.init(this, /* native exopackage */ false);

}

}

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