Question
Please help me make my code look like the image below, I can only get the one curve to work. Thank you for your help!!!
Please help me make my code look like the image below, I can only get the one curve to work. Thank you for your help!!!
import java.awt.*; import javax.swing.*;
public class U extends JFrame{ public U(){ getContentPane().setLayout(new BorderLayout()); getContentPane().add(new DrawXSquare(), BorderLayout.CENTER);
}
public static void main(String[] args){ U frame = new U(); frame.setSize(400,400); frame.setTitle("U"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setLocationRelativeTo(null); frame.setVisible(true); } class DrawXSquare extends JPanel{ double f(double x){ return x*x; } public void drawFunction(){ repaint(); } protected void paintComponent (Graphics g){ super.paintComponent(g); g.drawLine(10, 200, 390, 200); g.drawLine(200, 30, 200, 390);
g.drawLine(390, 200, 370, 190); g.drawLine(390, 200, 370, 210); g.drawLine(200, 30, 190, 50); g.drawLine(200, 30, 210, 50);
g.drawString("x", 390, 170); g.drawString("y", 220, 40);
Polygon p = new Polygon(); double scaleFactor = 0.01; for (int x = -100; x
NO/MD -OXStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started