Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

This is the code you will start with: //Michael Ryan //Lab 05 GUI 1 Build a non-functional GUI //2.18.2021 import java.awt.*; import java.awt.event.*; import javax.swing.JButton;

This is the code you will start with:

//Michael Ryan //Lab 05 GUI 1 Build a non-functional GUI //2.18.2021

import java.awt.*;

import java.awt.event.*;

import javax.swing.JButton;

import java.awt.Font;

//figure class creation public class FigureProcess extends Frame implements ActionListener { //label variables

private Label LabelWidth;

private Label Labellength;

private Label Labelradius;

private Label Labelheight;

//title variables

private Label FigTitle;

private Label myTitleLabel;

//text field variables

private TextField TextWidth;

private TextField TextLenght;

private TextField TextRadius;

private TextField TextHeight;

//constructor

public FigureProcess()

{

setLayout(new FlowLayout());

//setting label title

myTitleLabel = new Label("The Figure Center ");

add(myTitleLabel);

//setting font

Font fontTit = new Font("Verdana", Font.BOLD, 26);

myTitleLabel.setFont(fontTit);

add(myTitleLabel);

setLayout(new FlowLayout());

//title for radio button

FigTitle = new Label("Select a figure ");

add(FigTitle);

//font set for radio button

Font font1 = new Font("Verdana", Font.BOLD, 26);

FigTitle.setFont(font1);

add(FigTitle);

//radio button created

CheckboxGroup RadioButton = new CheckboxGroup();

add(new Checkbox("Rectangle",false, RadioButton));

add(new Checkbox("Box",false,RadioButton));

add(new Checkbox("Circle",false,RadioButton));

add(new Checkbox("Cylinder",false,RadioButton));

//label and textfields created

LabelWidth = new Label("Enter an Width");

add(LabelWidth);

TextWidth = new TextField(10);

add(TextWidth);

Labellength=new Label("Enter Length");

add(Labellength);

TextLenght = new TextField(10);

add(TextLenght);

Labelradius = new Label("Enter an Radius");

add(Labelradius);

TextRadius = new TextField(10);

add(TextRadius);

Labelheight = new Label("Enter an Height");

add(Labelheight);

TextHeight = new TextField(10);

add(TextHeight);

TextWidth.addActionListener(this);

TextLenght.addActionListener(this);

TextRadius.addActionListener(this);

TextHeight.addActionListener(this);

//process Button created

JButton ProcessButton = new JButton();

ProcessButton.setText("Click to process");

add(ProcessButton);

//setting frame size

setTitle("Figure Process");

setSize(490,300);

setVisible(true);

}

//Creation of method main

public static void main(String[] args)

{

//object created for the class

new FigureProcess();

}

//action event handler creation

@Override

public void actionPerformed(ActionEvent evt)

{

}

}

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

Lab 6 - Advanced Java Programming GUI 2 Add Functionality to a GUI Goals: Be able to: Add an ActionListener to a GUI Process data based on the ActionListener Instructions 1. Create 2 new Exception types: a. Less ThanMinimumException b. Greater TahnMaximumException 2. Modify the program from GUI_Labl by adding actionListeners for your radioButtons and your process button 3. Modify the GUI from GUI_LABI to use the actionListener. a. Make components invisible (setVisible(false)) i. Set the GUI so that the process button, the textFields and the textField labels are not visible when the program starts ii. Sample GUI GUI_LAB2 X The Figure Center Select a figure. Rectangle Box Circle Cylinder 0 0 b. Make components visible based on the radioButtons i. If the rectangle button is selected then only the width, height and process components should be shown 1. Sample GUI Rev. 2/16/2021 5:52 PM QUESTIONS???..OF COURSE YOU HAVE QUESTIONS!!! PLEASE CHECK OUT AND POST IN THE PROGRAMMING FORUM There are Lab 6 - Advanced Java Programming GUI 2 Add Functionality to a GUI Lab 06 GUI 02 The Figure Center Enter Width Select a figure Rectangle Box Circle Cylinder Enter Height Click to Process ii. If the box button is selected then only the width, length, height and process components should be shown 1. Sample GUI GULLAB2 The Figure Center Enter Width Enter Length Select a figure. Rectangle .Box Circle Cylinder Enter Height Click to Process ii. If the circle button is selected then only the radius and process components should be shown 1. Sample GUI Rev. 2/16/2021 5:52 PM QUESTIONS???...OF COURSE YOU HAVE QUESTIONS!!! PLEASE CHECK OUT AND POST IN THE PROGRAMMING FORUM The Call Lab 6 - Advanced Java Programming GUI 2 Add Functionality to a GUI GUL_LAB2 The Figure Center Select a figure Rectangle Box Enter Radius Circle Cylinder Click to Process iv. If the cylinder button is selected then only the radius, length and process components should be shown 1. Sample GUI Lab 06 GUI 02 The Figure Center Enter Length Select a figure. Rectangle Box Circle Cylinder Enter Radius Click to Process v. If you have put your components on individual panels then all you need do is use the appropriate panel's setVisible() method, otherwise you will need to use each components setVisible Rev. 2/16/2021 5:52 PM QUESTIONS???..OF COURSE YOU HAVE QUESTIONS!!! PLEASE CHECK OUT AND POST IN THE PROGRAMMING FORUM Lab 6 - Advanced Java Programming GUI 2 Add Functionality to a GUI method. You should NOT remove or add components to the GUI. vi. The user should be able to click the buttons in any order and have the GUI change in response to those selected radio buttons. (Hint: as you make some items visible you must make other components invisible.) c. When the Process button is pressed i. If the data entered for width, height, length or radius is less than the minimum or greater than the maximum then the background of the offending textField should turn a shade of yellow. Throw and catch the appropriate exception. Print the message to the console. static int maxWidth = static int maxHeight = 300; static int maxlength = 300; static int maxRadius = 400; static int minwidth = 50; static int minHeight = 50; static int minLength = 50; d. static int minRadius = 50; 300; i. If the user enters non-numeric data or no data your program should catch the error then the background of the offending textField. should turn a shade of red. Throw and catch the appropriate exception. Print the message to the console. ii. Users can then try again to enter data. iii. Draw the figure requested when there are no errors. 1. If the user requests a rectangle or a circle just provide thode simple figures. 2. If a user wants a box then you must draw a Box and a base (width and height) 3. If a user wants a cylinder then you must draw a Cylinder and a base (radius, radius - radius /2) 4. SAMPLES These are composite. I pasted the Figure Center over the drawing for convenience. SAMPLES WITH GOOD DATA Rev. 2/16/2021 5:52 PM QUESTIONS??? OF COURSE YOU HAVE QUESTIONS!!! PLEASE CHECK OUT AND POST IN THE PROGRAMMING FORUM

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

3. An initial value (anchoring).

Answered: 1 week ago

Question

c. What were you expected to do when you grew up?

Answered: 1 week ago

Question

d. How were you expected to contribute to family life?

Answered: 1 week ago

Question

e. What do you know about your ethnic background?

Answered: 1 week ago