Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Change the following application such that a SceneShape object in selected state is drawn with a dashed blue rectangle around it, with small blue squares

Change the following application such that a SceneShape object in selected state is drawn with a dashed blue rectangle around it, with small blue squares (side size=6 pixels) marking the corners.

Hints: You may use method GeneralPath.getBounds2D() to get the enclosing rectangle. Use method Graphics2D.setStroke(Stroke s) with a BasicStroke parameter

It should look as follows

image text in transcribed

import java.awt.*; import java.awt.geom.*; import java.awt.event.*; import javax.swing.*; /** A program that allows users to edit a scene composed of items. */ public class SceneEditor { public static void main(String[] args) { JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); final SceneComponent scene = new SceneComponent(); JButton houseButton = new JButton("House"); houseButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { scene.add(new HouseShape(20, 20, 50)); } }); JButton carButton = new JButton("Car"); carButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { scene.add(new CarShape(20, 20, 50)); } }); JButton removeButton = new JButton("Remove"); removeButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { scene.removeSelected(); } }); JPanel buttons = new JPanel(); buttons.add(houseButton); buttons.add(carButton); buttons.add(removeButton); frame.add(scene, BorderLayout.CENTER); frame.add(buttons, BorderLayout.NORTH); frame.setSize(300, 300); frame.setVisible(true); } } 
House Car Remove House Car Remove

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

Database Systems For Advanced Applications 15th International Conference Dasfaa 2010 Tsukuba Japan April 2010 Proceedings Part 1 Lncs 5981

Authors: Hiroyuki Kitagawa ,Yoshiharu Ishikawa ,Wenjie Li ,Chiemi Watanabe

2010th Edition

3642120253, 978-3642120251

More Books

Students also viewed these Databases questions