Hi. I have written PositiveCartesian class. It is very flexibile and easy for drawing cartesian coordinate system.
We can define position of cartesian on panel, names of axis, numbers on axis, size of cartesian in pixels,...

It may be useful for someone, so I want to share my code here:



class: PositiveCartesian.java
Java Code:
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.RenderingHints;

public class PositiveCartesian {
	int firstAxisLength;
	int secondAxisLength;
	String firstName;
	String secondName;
	int numberOfFirstCoordNumbers;
	int numberOfSecondCoordNumbers;
	double numbersDistanceFromCartesian;
	int distanceOfCartesianFromPanelXCoord;
	int distanceOfCartesianFromPanelYCoord;
	int numberOfPixelsByNumber;
	boolean populateWithAdditionalNumbers = false;

	
	public static final int FIRST_LENGHT = 10;
	public static final int SECOND_LENGHT = 5;
	
	// size of start coordinate lenght
	public static final int ORIGIN_COORDINATE_RADIUS = 6;
	
	// distance of strings (numbers) from cartesian coordiante system
	public static final int STRING_DISTANCE_FROM_CARTESIAN = 20;
	
	public PositiveCartesian(int firstAxisLength, int secondAxisLength) {
		this.firstAxisLength = firstAxisLength;
		this.secondAxisLength = secondAxisLength;
		firstName = "X";
		secondName = "Y";
		numberOfFirstCoordNumbers = 10;
		numberOfSecondCoordNumbers = 10;
		numbersDistanceFromCartesian = 20;
		distanceOfCartesianFromPanelXCoord = 50;
		distanceOfCartesianFromPanelYCoord = 50;
	}
	
	public void drawCartesian(Graphics g) {
		
		Graphics2D g2 = (Graphics2D) g;
		
		g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
				RenderingHints.VALUE_ANTIALIAS_ON);
		
		// we are setting default distance of cartesian from panel and that is 50px width, 50px height
		setDistanceOfCartesianFromPanel(distanceOfCartesianFromPanelXCoord, distanceOfCartesianFromPanelYCoord);
		
		// x-axis
		g2.drawLine((int)distanceOfCartesianFromPanelXCoord, (int)(distanceOfCartesianFromPanelYCoord + secondAxisLength),
					(int)(distanceOfCartesianFromPanelXCoord + firstAxisLength), (int)(distanceOfCartesianFromPanelYCoord + secondAxisLength));
		
		
		// y-axis
		g2.drawLine((int)distanceOfCartesianFromPanelXCoord, (int)(distanceOfCartesianFromPanelYCoord + secondAxisLength),
				(int)distanceOfCartesianFromPanelXCoord, (int)distanceOfCartesianFromPanelYCoord);
		
		
		// x-axis arrow
		g2.drawLine((int)(distanceOfCartesianFromPanelXCoord + firstAxisLength - FIRST_LENGHT),
				(int)(distanceOfCartesianFromPanelYCoord + secondAxisLength - SECOND_LENGHT),
				(int)(distanceOfCartesianFromPanelXCoord + firstAxisLength), (int)(distanceOfCartesianFromPanelYCoord + secondAxisLength));
		g2.drawLine((int)(distanceOfCartesianFromPanelXCoord + firstAxisLength - FIRST_LENGHT),
				(int)(distanceOfCartesianFromPanelYCoord + secondAxisLength + SECOND_LENGHT),
				(int)(distanceOfCartesianFromPanelXCoord + firstAxisLength), (int)(distanceOfCartesianFromPanelYCoord + secondAxisLength));
		
		// y-axis arrow
		g2.drawLine((int)(distanceOfCartesianFromPanelXCoord - SECOND_LENGHT),
					(int)(distanceOfCartesianFromPanelYCoord + FIRST_LENGHT),
					(int)distanceOfCartesianFromPanelXCoord, (int)distanceOfCartesianFromPanelYCoord);
		g2.drawLine((int)(distanceOfCartesianFromPanelXCoord + SECOND_LENGHT), 
				(int)(distanceOfCartesianFromPanelYCoord + FIRST_LENGHT),
				(int)distanceOfCartesianFromPanelXCoord, (int)distanceOfCartesianFromPanelYCoord);
		
		// coordinate origin point
		g2.fillOval((int)(distanceOfCartesianFromPanelXCoord - (ORIGIN_COORDINATE_RADIUS / 2)), 
				(int)(distanceOfCartesianFromPanelYCoord + secondAxisLength - (ORIGIN_COORDINATE_RADIUS / 2)),
				ORIGIN_COORDINATE_RADIUS, ORIGIN_COORDINATE_RADIUS);
		
		
		// draw names of axis and origin point
		g2.drawString("X", (int)(distanceOfCartesianFromPanelXCoord + firstAxisLength - STRING_DISTANCE_FROM_CARTESIAN / 2),
				(int)(distanceOfCartesianFromPanelYCoord + secondAxisLength + STRING_DISTANCE_FROM_CARTESIAN));
		g2.drawString("Y", (int)(distanceOfCartesianFromPanelXCoord - STRING_DISTANCE_FROM_CARTESIAN),
				(int)(distanceOfCartesianFromPanelYCoord + STRING_DISTANCE_FROM_CARTESIAN / 2));
		g2.drawString("(0, 0)", (int)(distanceOfCartesianFromPanelXCoord - STRING_DISTANCE_FROM_CARTESIAN),
				(int)(distanceOfCartesianFromPanelYCoord + secondAxisLength + STRING_DISTANCE_FROM_CARTESIAN));
		
		// draw first-axis numbers
		drawNumbersOnFirstAxis(g2, numberOfFirstCoordNumbers);
		
		//draw second-axis numbers
		drawNumbersOnSecondAxis(g2, numberOfSecondCoordNumbers);
	
	
	}
	
	public void setNamesOfAxis(String firstName, String secondName) {
		this.firstName = firstName;
		this.secondName = secondName;
	}
	
	public void setNumbersOfCordinateNumbers(int firstCoordNumbers, int secondCoordNumbers) {
		this.numberOfFirstCoordNumbers = firstCoordNumbers;
		this.numberOfSecondCoordNumbers = secondCoordNumbers;
	}
	
	public int getNumberOfPixelsByNumber() {
		if((firstAxisLength / numberOfFirstCoordNumbers) < (secondAxisLength / numberOfSecondCoordNumbers))
			numberOfPixelsByNumber = firstAxisLength / numberOfFirstCoordNumbers;
		else
			numberOfPixelsByNumber = secondAxisLength / numberOfSecondCoordNumbers;
		
		return numberOfPixelsByNumber;
	}
	
	public void setDistanceOfCartesianFromPanel(int x, int y) {
		this.distanceOfCartesianFromPanelXCoord = x;
		this.distanceOfCartesianFromPanelYCoord = y;
	}
	
	public void setNumbersDistanceFromCartesian(int distance) {
		this.numbersDistanceFromCartesian = distance;
	}
	
	public void populateAxisWithAdditionalNumbers(boolean populate) {
		this.populateWithAdditionalNumbers = populate;
		
			int numberOfPixelsByNumber = getNumberOfPixelsByNumber();
			
			
			
	}
	
	public void drawNumbersOnFirstAxis(Graphics2D g2, int numberOfNumbersOnFirstAxis) {
		int numberOfPixelsByNumber = getNumberOfPixelsByNumber();
		
		for(int i = 1; i < numberOfNumbersOnFirstAxis; i++) {
			g2.drawLine((int)(distanceOfCartesianFromPanelXCoord + (i * numberOfPixelsByNumber)),
					(int)(distanceOfCartesianFromPanelYCoord + secondAxisLength - SECOND_LENGHT),
					(int)(distanceOfCartesianFromPanelXCoord + (i * numberOfPixelsByNumber)),
					(int)(distanceOfCartesianFromPanelYCoord + secondAxisLength + SECOND_LENGHT));
			g2.drawString(Integer.toString(i),
					(int)(distanceOfCartesianFromPanelXCoord + (i * numberOfPixelsByNumber) - 4),
					(int)(distanceOfCartesianFromPanelYCoord + secondAxisLength + STRING_DISTANCE_FROM_CARTESIAN));
		}
		
			if(populateWithAdditionalNumbers) {
				int currentPopulatePixelsOnXCoord = numberOfPixelsByNumber * numberOfFirstCoordNumbers;
			
				if(currentPopulatePixelsOnXCoord < firstAxisLength) {
					int additionalNumbers = 0;
					while((currentPopulatePixelsOnXCoord + (additionalNumbers * numberOfPixelsByNumber)) < firstAxisLength - 20) {
						g2.drawLine((int)(distanceOfCartesianFromPanelXCoord + ((additionalNumbers + numberOfNumbersOnFirstAxis) * numberOfPixelsByNumber)),
								(int)(distanceOfCartesianFromPanelYCoord + secondAxisLength - SECOND_LENGHT),
								(int)(distanceOfCartesianFromPanelXCoord + ((additionalNumbers + numberOfNumbersOnFirstAxis) * numberOfPixelsByNumber)),
								(int)(distanceOfCartesianFromPanelYCoord + secondAxisLength + SECOND_LENGHT));
						
						g2.drawString(Integer.toString(additionalNumbers + numberOfNumbersOnFirstAxis),
								(int)(distanceOfCartesianFromPanelXCoord + (((additionalNumbers + numberOfNumbersOnFirstAxis) * numberOfPixelsByNumber) - 4)),
								(int)(distanceOfCartesianFromPanelYCoord + secondAxisLength + STRING_DISTANCE_FROM_CARTESIAN));
						
						additionalNumbers += 1;
					}
				}
			}
	}
	
	public void drawNumbersOnSecondAxis(Graphics2D g2, int numberOfNumbersOnSecondAxis) {
		int numberOfPixelsByNumber = getNumberOfPixelsByNumber();
		
		for(int i = 1; i < numberOfNumbersOnSecondAxis; i++) {
			g2.drawLine((int)distanceOfCartesianFromPanelXCoord - SECOND_LENGHT,
					(int)distanceOfCartesianFromPanelYCoord + secondAxisLength - (i * numberOfPixelsByNumber), 
					(int)distanceOfCartesianFromPanelXCoord + SECOND_LENGHT,
					(int)distanceOfCartesianFromPanelYCoord + secondAxisLength - (i * numberOfPixelsByNumber));
			g2.drawString(Integer.toString(i), 
					(int)distanceOfCartesianFromPanelXCoord - STRING_DISTANCE_FROM_CARTESIAN, 
					(int)distanceOfCartesianFromPanelYCoord + secondAxisLength - (i * numberOfPixelsByNumber));
		}
			
		if(populateWithAdditionalNumbers) {
				int currentPopulatePixelsOnYCoord = numberOfPixelsByNumber * numberOfSecondCoordNumbers;
			
				if(currentPopulatePixelsOnYCoord < secondAxisLength) {
					int additionalNumbers = 0;
					while((currentPopulatePixelsOnYCoord + (additionalNumbers * numberOfPixelsByNumber)) < secondAxisLength - 20) {
						g2.drawLine((int)distanceOfCartesianFromPanelXCoord - SECOND_LENGHT,
								(int)distanceOfCartesianFromPanelYCoord + secondAxisLength - ((additionalNumbers + numberOfNumbersOnSecondAxis) * numberOfPixelsByNumber), 
								(int)distanceOfCartesianFromPanelXCoord + SECOND_LENGHT,
								(int)distanceOfCartesianFromPanelYCoord + secondAxisLength - ((additionalNumbers + numberOfNumbersOnSecondAxis) * numberOfPixelsByNumber));
						g2.drawString(Integer.toString((additionalNumbers + numberOfNumbersOnSecondAxis)), 
								(int)distanceOfCartesianFromPanelXCoord - STRING_DISTANCE_FROM_CARTESIAN, 
								(int)distanceOfCartesianFromPanelYCoord + secondAxisLength - ((additionalNumbers + numberOfNumbersOnSecondAxis) * numberOfPixelsByNumber));
						
						additionalNumbers += 1;
					}
				}
		}
	}
}



Here is a simple program which explain using of cartesian class:

class: PositiveCartesianUI.java
Java Code:
import java.awt.Graphics;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.SwingUtilities;


public class PositiveCartesianUI {
	public static void main(String[] args) {
		SwingUtilities.invokeLater(new Runnable() {
			
			@Override
			public void run() {
				PositiveCartesianFrame frame = new PositiveCartesianFrame();
				frame.showUI();
			}
		});
	}
}

class PositiveCartesianFrame extends JFrame {
	PositiveCartesianPanel panel;
	
	public PositiveCartesianFrame() {
		panel = new PositiveCartesianPanel();
		getContentPane().add(panel);
	}
	
	public void showUI() {
		setTitle("Basic user interface program");
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setSize(1010,850);
		setVisible(true);
	}
}

class PositiveCartesianPanel extends JPanel {
	PositiveCartesian cartesian;
	
	public PositiveCartesianPanel() {

	}
	
	public void paintComponent(Graphics g) {
		super.paintComponent(g);
		
		cartesian = new PositiveCartesian(750, 650);
		cartesian.populateAxisWithAdditionalNumbers(true);
		cartesian.drawCartesian(g);
	}
}