<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">import javax.swing.*;
import java.awt.*;

public class Drawing {

    private void buildUI(Container container) {
        container.setLayout( new BoxLayout(container, BoxLayout.PAGE_AXIS) );
        CoordinateArea coordinateArea = new CoordinateArea(this);  // see below
        container.add(coordinateArea);
    }

    private static void createAndShowGUI() {
        JFrame.setDefaultLookAndFeelDecorated(true);
        JFrame frame = new JFrame("DrawThingsDemo");
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        Drawing controller = new Drawing();
        controller.buildUI(frame.getContentPane());
        frame.pack();
        frame.setVisible(true);
    }

    public static void main(String[] args) {
        SwingUtilities.invokeLater(new Runnable() {   
        	public void run() { createAndShowGUI(); }   
        	}
        );          // end of invokeLater
    }  // end of main

    @SuppressWarnings("serial")
    
	public static class CoordinateArea extends JComponent {
		//Point point = null;
        Drawing controller;
        Dimension preferredSize = new Dimension(900,800); // choose size!!
        Color gridColor;
    
        public CoordinateArea(Drawing controller) {
            this.controller = controller;
            
            //Add border of 10 pixels at L and bottom, and 4 pixels at the top and R.
            setBorder(BorderFactory.createMatteBorder(24,10,70,4,Color.RED));
            
            setBackground(Color.BLACK);
            setOpaque(true);
        }  // end of constructor
    
        public Dimension getPreferredSize() {
            return preferredSize;
        }
    
        public void paintComponent(Graphics g) {
            if (isOpaque()) { g.setColor(getBackground()); //Paint bg if we're opaque.
                              g.fillRect(0, 0, getWidth(), getHeight());
            }
            g.setColor(Color.GREEN);  //Paint colour , even ...drawGrid(g, 20);  below
            g.drawLine(778,200,400,538); //the numbers are in the order x_1,y_1,x_2,y_2 for the
              // x and y coords of the starting point (1) and end point (2)

            g.setColor(Color.ORANGE);
            g.fillRect(13, 423, 367, 107); // the numbers are in the same order, but this
              // time for the coords of the diagonal
            
            int [] xcoords, ycoords;
            xcoords = new int[4];
            ycoords = new int[xcoords.length];
            for (int i=0; i&lt;xcoords.length; i++) { 
            	xcoords[i] = ((int)(500 * Math.random() - 100))  + 300; 
            	ycoords[i] = ((int)(200 * Math.random() - 100))  + 300;  
            }
            g.setColor(Color.BLUE);
            g.drawPolyline( xcoords, ycoords, xcoords.length);
            
            int noOfPoints = 8000;
            xcoords = new int[noOfPoints + 1];
            ycoords = new int[xcoords.length];
            for (int i=0; i&lt;xcoords.length; i++) { 
            	xcoords[i] = (int)(250 * Math.cos(i*2*Math.PI/noOfPoints)) + 400; 
            	ycoords[i] = (int)(250 * Math.sin(i*2*Math.PI/noOfPoints)) + 300;
            }
            g.setColor(Color.MAGENTA);
            g.drawPolyline( xcoords, ycoords, xcoords.length);
            
            noOfPoints = 100;
            //xcoords = new int[noOfPoints+1];
            //ycoords = new int[noOfPoints+1];
            for (int i=0; i&lt;xcoords.length; i++) { 
            	xcoords[i] = i + 100; 
            	ycoords[i] = (int)(5 * Math.exp( (double) i * 0.1)) + 300;
            }
            g.setColor(Color.WHITE);
            g.drawPolyline( xcoords, ycoords, xcoords.length);
            
        } // end of paintComponent

    }  // end of CoordinateArea class

}  // end of class Drawing
</pre></body></html>