Create a GUI for your Agile or Waterfall program from Lab 3. Add these components to AgileWaterfallGUI.form.
Question:
Create a GUI for your Agile or Waterfall program from Lab 3. Add these components to AgileWaterfallGUI.form. Again, use these names. q1 * JTextField `projectName` * JSlider `peopleOnTeam` This should take values between 1 and 300. Add JLabels with the text "1" at the start, and "300" at the end, to indicate the start and end values. * JCheckBox `firmDeadlines` * JCheckBox `experienceAllPhases` * JCheckBox `qualityControl` * JCheckBox `earlyIntegration` * JCheckBox `earlyWorkingModels` * JButton `recommendMethodology` * JLabel `recommendation` Add more JLabels as appropriate, for example, to indicate what to type into the JTextField, and label the JSlider with a name, and max and min values. Your program may re-use the `agileOrWaterfall` method you wrote in Lab 3.
Add a ActionListener (click) event listener to the `recommendMethodology` button. When clicked, this button will read the data entered, and recommend Waterfall or Agile or either for a development method for the project. Display the recommendation in the `recommendation` JLabel. Use the provided Strings `AGILE`, `WATERFALL` and `EITHER` and `RECOMMENDATION_TEMPLATE` to display the result. Your GUI program should use a JLabel and the `recommendationTemplate` format String provided to display something like "Big IBM Project could use Waterfall" or "My assignment could use Agile" or "Banking App could use either"
package week_8.q2_agile_waterfall; /* The instructions are in grades/Lab 8 Questions.md * * For this lab, you probably don't need to modify this class. */ import sun.security.util.ObjectIdentifier; import javax.swing.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; public class AgileWaterfallProgram extends JFrame { public static void main(String[] args) { AgileWaterfallGUI gui = new AgileWaterfallGUI(); } private JPanel mainPanel; private JTextField projectName; private JSlider peopleOnTeam; private JCheckBox firmDeadlines; private JCheckBox experienceAllPhases; private JCheckBox qualityControl; private JCheckBox earlyIntegration; private JCheckBox earlyWorkingModels; private JLabel recommendation; private JButton recommenMethodologyButton; private JButton recommendMethodology; public final static String AGILE = "Agile"; public final static String WATERFALL = "Waterfall"; public final static String EITHER = "either"; public final static String RECOMMENDATION_TEMPLATE = "%s could use %s"; AgileWaterfallProgram() { setContentPane(mainPanel); pack(); setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); setVisible(true); recommendMethodology.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { try { int teamSize = peopleOnTeam.getValue(); boolean deadline = firmDeadlines.isSelected(); boolean allPhase = experienceAllPhases.isSelected(); boolean earlyModel = earlyWorkingModels.isSelected(); boolean quality = qualityControl.isSelected(); boolean earlyInt = earlyIntegration.isSelected(); int agileScore = 0; int waterfallScore = 0; String name = projectName.getText(); if (teamSize > 30) { waterfallScore = waterfallScore + 1; } if (deadline) { waterfallScore = waterfallScore + 1; } if (allPhase) { agileScore = agileScore + 1; } if (quality) { waterfallScore = waterfallScore + 1; } if (earlyModel) { agileScore = agileScore + 1; } if (earlyInt) { agileScore = agileScore + 1; } if (agileScore > waterfallScore) { recommendation.setText(name + " could use " + AGILE); } if (waterfallScore > agileScore) { recommendation.setText(name + " could use " + WATERFALL); } if (waterfallScore == agileScore) { recommendation.setText(name + " could use " + EITHER); } } catch (Exception NullPointerException) { System.out.println("Null pointer exception"); } } }); } public void setMainPanel(JPanel mainPanel) { this.mainPanel = mainPanel; } public void setProjectName(JTextField projectName) { this.projectName = projectName; } public void setPeopleOnTeam(JSlider peopleOnTeam) { this.peopleOnTeam = peopleOnTeam; } public void setQualityControl(JCheckBox qualityControl) { this.qualityControl = qualityControl; } public void setExperienceAllPhases(JCheckBox experienceAllPhases) { this.experienceAllPhases = experienceAllPhases; } public void setEarlyIntegration(JCheckBox earlyIntegration) { this.earlyIntegration = earlyIntegration; } public void setRecommendation(JLabel recommendation) { this.recommendation = recommendation; } }