1 import java.awt.*; 2 import java.awt.event.*; 4 import javax.swing.*; 5 public class ShapeColorDraw extends JPanel { 6 //Setup the frame 7 8 public static void main(String[] args) { 9 10 JFrame window = new JFrame("ShapeColorDraw"); 11 12 window.setContentPane( new ShapeColorDraw() ); 13 14 window.setSize(1000,700); 15 L 16 window.setlocation(300,200); 17 18 window.setDefaultCloseOperation(JFrame. EXIT_ON_CLOSE); 19 20 window.setVisible(true); 21 22 } 23 public void paint(Graphics g) { 24 //custom color String hexColor = new String("Ox45e5B"); g. setColor(Color.decode(hexColor)); String hexColor1 = new String("#ffc@d4"); g.setColor(Color.decode(hexColor1)); 29 25 26 27 28 String hexColor2 = new String("#003399"); g. setColor(Color.decode(hexColor2)); String hexColor3 = new String("#ff1493"); g.setColor(Color.decode(hexColor3)); 30 31 32 33 //Fill Rectangles with colors g.fillRect(70, 90, 450, 80); g. fillRect(300,300,300,300); g. fillRect(200,100,50,50); g.fillRect(400,200,100,50); 34 35 36 37 38 39 40 } 41 }

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

Please, could you help me with my code? (I would like to attribute each color to one rectangle.)

.mport java.awt.*;
mport java.awt.event.*;
ShapeColorDraw
Transcribed Image Text:.mport java.awt.*; mport java.awt.event.*; ShapeColorDraw
s Window Help
1 import java.awt.*;
2 import java.awt.event.*;
3
4 import javax.swing.*;
5 public class ShapeColorDraw extends JPanel {
6 //Setup the frame
7
8 public static void main(String[] args) {
9.
10 JFrame window = new JFrame ("ShapeColorDraw");
11
12 window.setContentPane( new ShapeColorDraw() );
13
14 window.setSize(1000,700);
15 L
16 window.setLocation(300,200);
17
18 window.setDefaultCloseOperation(JFrame. EXIT_ON_CLOSE);
19
20 window.setVisible(true);
21
22 }
23 public void paint(Graphics g) {
24
//custom color
String hexColor = new String("Ox45e5B");
g. setColor (Color.decode (hexColor));
String hexColor1
g.setColor(Color.decode(hexColor1));
String hexColor2 = new String("#003399");
g.setColor(Color.decode(hexColor2));
String hexColor3 = new String("#ff1493");
g.setColor (Color.decode(hexColor3));
25
26
27
= new String("#ffc0d4");
28
29
30
31
32
33
//Fill Rectangles with colors
g.fillRect(70, 90, 450, 80);
g.fillRect(300,300,300,300);
g.fillRect(200,100,50,50);
g.fillRect(400, 200,100,50);
34
35
36
37
38
39
40 }
41 }
III
Transcribed Image Text:s Window Help 1 import java.awt.*; 2 import java.awt.event.*; 3 4 import javax.swing.*; 5 public class ShapeColorDraw extends JPanel { 6 //Setup the frame 7 8 public static void main(String[] args) { 9. 10 JFrame window = new JFrame ("ShapeColorDraw"); 11 12 window.setContentPane( new ShapeColorDraw() ); 13 14 window.setSize(1000,700); 15 L 16 window.setLocation(300,200); 17 18 window.setDefaultCloseOperation(JFrame. EXIT_ON_CLOSE); 19 20 window.setVisible(true); 21 22 } 23 public void paint(Graphics g) { 24 //custom color String hexColor = new String("Ox45e5B"); g. setColor (Color.decode (hexColor)); String hexColor1 g.setColor(Color.decode(hexColor1)); String hexColor2 = new String("#003399"); g.setColor(Color.decode(hexColor2)); String hexColor3 = new String("#ff1493"); g.setColor (Color.decode(hexColor3)); 25 26 27 = new String("#ffc0d4"); 28 29 30 31 32 33 //Fill Rectangles with colors g.fillRect(70, 90, 450, 80); g.fillRect(300,300,300,300); g.fillRect(200,100,50,50); g.fillRect(400, 200,100,50); 34 35 36 37 38 39 40 } 41 } III
Expert Solution
steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Knowledge Booster
Unreferenced Objects
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education