Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

This is one of my homework: Draw the word TWO using the Line2D.Double and Ellipse2D.Double classes in the Java library. Make a project and create

This is one of my homework:

Draw the word TWO using the Line2D.Double and Ellipse2D.Double classes in the Java library.

Make a project and create a class called TwoComponent to do the drawing. There is no starter file this time. But a TwoViewer class is provided

Your drawing should follow these specifications.

1,Each letter is 40 pixels wide and 50 pixels height

2,There is a 10 pixel gap between letters

3,The upper left hand corner of the T is at (20,50)

4.Draw the T in red

5,Draw the W in blue

6,Fill the ellipse for the O (Do not draw it). Use a custom color where red is 200, green is 255, and blue is 10.

and the TwoViewer.java is:

import javax.swing.*; public class TwoViewer { public static void main(String[] args) { JFrame frame = new JFrame(); frame.setSize(300, 400); frame.setTitle("TWO frame"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); TwoComponent component = new TwoComponent(); frame.add(component); frame.setVisible(true); } } 

--------------------------------------------------------------

I write my code but something is wrong.My code can output "TW" , but it's really small.there is my code

import java.awt.Color; import java.awt.Graphics; import java.awt.Graphics2D; import javax.swing.JComponent;

public class TwoComponent extends JComponent { private static final long serialVersionUID = 1L;

public void paintComponent(Graphics g) { Graphics2D g2 = (Graphics2D) g; g2.setColor(Color.RED); g2.drawString("T", 20, 100); g2.setColor(Color.BLUE); g2.drawString("W", 30, 100); }

}

image text in transcribed

The first one is what I actually output and the second one is what I should output

Image Expected

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 Design Query Formulation And Administration Using Oracle And PostgreSQL

Authors: Michael Mannino

8th Edition

1948426951, 978-1948426954

More Books

Students also viewed these Databases questions

Question

8. Explain competency models and the process used to develop them.

Answered: 1 week ago