Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Why won't this code work in Netbeans? How can I get it to? This is the output I need: If you want an easier way

Why won't this code work in Netbeans? How can I get it to?

This is the output I need:

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

If you want an easier way to copy and paste the code, it is the code from a previous question here:

https://www.chegg.com/homework-help/questions-and-answerseed-help-following-project-java-swing-program-must-able-work-netbeans-please-thank--third-q44859583?trackid=pSrkb1Dc

I cannot get this code to work in Netbeans, please help!!!

Drawing Shapes - O X Shape Type Oval Shape Drawing Fill Type Solid Color Red Width 100 Height x coordinate y coordinate Draw import java.awt. Color: import java.awt. Dimension: import java.awt.Grapbics: import java.awt. Point; import java.awt. Rectangle: public abstract class Shape extends Rectangle { private static final long serial Version UID = 1L; // instance variables private String color; private String shape; private static int count: // parameterized constructor public Shape(Point p, Dimension d, String color, String shape) { super(p, d); this.color = color; this.shape = shape; count++; Il method to set color of the graphics public void setColor(Graphics g) { if(color.equalsignoreCase("black")) g.setColor(Color.BLACK); else if(color.equalsignoreCase("red")) g.setColor(Color.RED); else if(color.equalsignoreCase("orange")) g.setColor(Color.ORANGE); else if(color.equalsignoreCase("yellow")) g.setColor(Color.YELLOW); else if(color.equalsignoreCase("green")) g.setColor(Color.GREEN); else if(color.equalsignoreCase("blue")) g.setColor(Color.BLUE); else if(color.equalsignoreCase("magenta")) g.setColor(Color.MAGENTA); // return shape type is solid or hollow public String getSolid() { return shape; // returns no of shapes draw public static int getNoOfShapes() { return count; Il abstract draw method public abstract void draw(Graphics g); Oval.java import java.awt. Dimension import java.awt Grapbics: import java.awt. Paint; public class Oval extends Shape { private static final long serial VersionUID = 1L Il parameterized constructor public Oval(Point p, Dimension d, String color, String shape) { super(p, d, color, shape); @Override public void draw(Graphics g) { Il drawing shape according to shape type if(getSolid().equalsignoreCase("hollow")) g.drawOval((int)getxo, (int)getY(), (int)getWidth(), (int)getHeight()); else if(getSolid().equalsignoreCase("solid")) g.filloval(int)getX(), (int)getY(), (int)getWidth(), (int) getHeight()); Rectangular.java import java.awt. Dimension: import java.awt.Graphics: import java.awt. Point; public class Rectangular extends Shape { private static final long serial VersionUID = 1L; Il parameterized constructor public Rectangular(Point p, Dimension d, String color, String shape) { super(p, d, color, shape); @Override public void draw(Graphics g) { // drawing shape according to shape type if(getSolid().equalslgnoreCase("hollow")) g.drawRect((int)getX(), (int)gety, (int)getWidth(), (int)getHeight()); else if(getSolid().equalsignoreCase("solid")) g.fillRect((int)getX(), (int)getY(), (int)getWidth(), (int)getHeight(); OutsideBounds.java // user defined exception public class OutsideBounds extends Exception { private static final long serial VersionUID = 1L; // parameterized constructor public OutsideBounds(String error Message) { // call super class parameterized constructor super(errorMessage); Drawing.java import java.awt. Dimension import java.awt.Grapbics: import java.awt. Point; import java.awt.event.ActionEvent; import java.awt.event ActionListener: import javax swing RorderFactory import javax.swing JButton import javax.swing.JComboBox; import javax.swing JFrame: shape=new JLabel("Shape Type"); fillType=new JLabel("Fill Type"); color=new JLabel("Color"); width=new JLabel("Width"); height=new JLabel("Height"); x=new JLabel("x coordinate"); y=new JLabel("y coordinate"); printCount=new JLabel("1"); cshape=new JComboBox (new String[] {"Oval","Rectangle"}); sfillType=new JComboBox (new Stringi ("Solid","Hollow"}); calor=new JComboBox (new String[] {"Black","Red", "Orange","Yellow","Green", "Blue", "Magenta")); twidth=new JTextField(); theight=new JTextField(); tx=new JTextField(): ty=new JTextField(); draw=new JButton("Draw"); panel=new JPanel(); Il set border with title to panel panel.setBorder(BorderFactory.create TitledBorder("Shape Drawing")); // add all controls into frame add(shape); add(fillType); add(color); add(width); add(height); add(x); add(y): add(printCount); add(cshape); add(ofillyre); add(color); add(twidth); add(theight); add(x); add(ty); add(draw); add(panel); // set bounds for all controls shape.setBounds (20.20. 100.30): shape.setBounds (20, 20, 100, 30); fillType.setBounds(20, 55, 100, 30); color.setBounds(20, 90, 100, 30); width.setBounds (20, 125, 100, 30); height.setBounds (20, 160, 100, 30); x.setBounds(20, 195, 100, 30); y.setBounds(20, 230, 100, 30); printCount.setBounds (285, 40, 20, 30); cshape.setBavods(140, 20, 100, 30); cfUlType.setBguods/140, 55, 100, 30); cealer.setBounds(140, 90, 100, 30); twidtb.setBounds(140, 125, 100, 30); tbeigbt.setBounds(140, 160, 100, 30); b.setBounds(140, 195, 100, 30); ty.setBounds(140, 230, 100, 30); draw.setBounds (230, 280, 80, 30); panel.setBounds(270, 20, 300, 250); // adding action listener to draw button draw.addActionListener(this); setVisible(true); // make frame visible Il private method to check all possible exceptions exceptions private void checkException() { try { shapeWidth=Integer.parseInt(twidtb.getText(); shape Height=Integer.parseInt(theight.getText(); shapeX=Integer.parseInt(tx.getText(); shape Y=Integer.parseInt(ty.getText(); if((shapeWidth+shapeX)>300 II (shapeHeight+shapeY)>250 Il shapeWidth300 II (shapeHeight+shapeY)>250 Il shapeWidth

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

Beginning C# 5.0 Databases

Authors: Vidya Vrat Agarwal

2nd Edition

1430242604, 978-1430242604

More Books

Students also viewed these Databases questions

Question

What does stickiest refer to in regard to social media

Answered: 1 week ago