Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Programming Practice Access the following Java source file: StopLight.java using this link. You should see a blank drawing ready for you as the artist to

Programming Practice

Access the following Java source file: StopLight.java using this link. You should see a blank drawing ready for you as the artist to begin your wo

Enter the Java code to draw a stoplight.

StopLight.java

// Delta College - CST 183 - Klingler // This application draws a stoplight import java.awt.*; import javax.swing.*; public class StopLight extends JPanel { public void paintComponent( Graphics g ) { // Set up drawing context super.paintComponent( g ); // Enter drawing code to create stoplight here } public static void main( String args[] ) { // Instantiate drawing panel StopLight drawPanel = new StopLight(); // Instantiate application object JFrame application = new JFrame(); // Add drawing panel to application application.add(drawPanel); // Set application attributes application.setSize( 300,500 ); application.setVisible( true ); application.setTitle( "My Stoplight" ); application.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE ); } } 

Expert Answer

image text in transcribedSrkKhan answered this

Was this answer helpful?

0

0

768 answers

PLEASE FIND THE CODE BELOW:

package graphichal;

// Delta College - CST 183 - Klingler // This application draws a stoplight

import java.awt.*; import javax.swing.*;

public class StopLight extends JPanel { public void paintComponent( Graphics g ) { // Set up drawing context super.paintComponent( g ); //draw base g.fillRect(200, 700, 300,30); //draw pipe g.fillRect(350, 500,30,200); //draw board for light g.fillRect(287, 250,150,400); //draw head g.fillArc(260, 200, 200, 200, 0, 180); //put lights g.setColor(Color.RED); g.fillOval(315, 300, 100, 100); g.setColor(Color.ORANGE); g.fillOval(315, 410, 100, 100); g.setColor(Color.GREEN); g.fillOval(315, 520, 100, 100); // Enter drawing code to create stoplight here }

public static void main( String args[] ) { // Instantiate drawing panel StopLight drawPanel = new StopLight(); // Instantiate application object JFrame application = new JFrame(); // Add drawing panel to application application.add(drawPanel);

// Set application attributes application.setSize( 500,500 ); application.setVisible( true ); application.setTitle( "My Stoplight" ); application.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE ); } }

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

Informix Database Administrators Survival Guide

Authors: Joe Lumbley

1st Edition

0131243144, 978-0131243149

More Books

Students also viewed these Databases questions

Question

Determine the amplitude and period of each function.

Answered: 1 week ago