делаю функцию для рисования прямоугольников

У меня проблема, я написал код для рисования прямоугольников. Я не могу запустить программу пробовал почти все максиум что вышло это при замене настого места на null, выдавало ошибку но давало запустить. Вот основной класс:

import javax.swing.*;
import java.awt.*;

import static libraries.paintRectangle.PR;

public class Main {

    public static void main(String[] args){

        System.out.println("All ok");

        JFrame window = new JFrame();
        window.setTitle("Ttrl");
        window.setSize(500, 500);
        window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        window.setVisible(true);
        PR(10,10,10,10, "#FFFFFF", true);
    }
    public static void p(Graphics g){
        Graphics graphic = (Graphics2D) g;
        System.out.println(g);
    }
}

Вот для прямоугольников:

package libraries;

import java.awt.*; // import library

import static libraries.paintRectangle.XYVariables.*; // dor global variables
public class paintRectangle { // class
    public static void PR( int x1_, int y1_, int width_, int height_, String color_, boolean fill_){ // function for draw rectangles
        setX1(x1_); // Setting variables {
        setY1(y1_);
        setWidth(width_);
        setHeight(height_);
        setColor(color_);
        setFill(fill_); // }

        paint_rectangle_sys(/*Problem her*/); // Calling directly drawing function
    }
    public static class XYVariables{ // Function for create variables for draw rectangle
       public static int x1 = 0; // x1 of rectangle
        public static int y1 = 0; // y1 of rectangle
        public static int width = 0; // width of rectangle
        public static int height = 0; // height of rectangle
        public static String color = "#FFFFFF"; // color of rectangle
        public static boolean fill = false; // variable for know is must program fill rectangle
    }
    public static void paint_rectangle_sys(Graphics2D graphic){ // Function what user mustn't call
        graphic.setColor(Color.decode(getColor())); // Setting color
        if(isFill()){
            graphic.fillRect(getX1(), getY1(), getWidth(), getHeight()); // If it's must to ill draw filled rectangle
        }else {
            graphic.drawRect(getX1(), getY1(), getWidth(), getHeight()); // Else draw not filled rectangle. (boolean variables have only two states, if it's not true it's false)
        }
    }
    public static int getX1() {
        return x1; // Getting first coordinate to draw rectangle
    }
    public static void setX1(int x1) {
        XYVariables.x1 = x1; // Setting first coordinate to draw rectangle
    }
    public static int getY1() {
        return y1; // Getting second coordinate to draw rectangle
    }
    public static void setY1(int y1) {
        XYVariables.y1 = y1; // Setting second coordinate to draw a rectangle
    }
    public static int getWidth() {
        return width; // Getting width to draw a rectangle
    }
    public static void setWidth(int width) {
        XYVariables.width = width; // Setting width to draw a rectangle
    }
    public static int getHeight() {
        return height; // Getting height to draw a rectangle
    }
    public static void setHeight(int height) {
        XYVariables.height = height; // Getting height to draw a rectangle
    }
    public static String getColor() {
        return color; // Getting color to draw a rectangle
    }
    public static void setColor(String color) {
        XYVariables.color = color; // Getting color to draw a rectangle
    }
    public static boolean isFill() {
        return fill; // Getting is program must to fill a drawn rectangle
    }
    public static void setFill(boolean fill) {
        XYVariables.fill = fill; // Setting is program must to fill a drawn rectangle
    }
}

Ответы (0 шт):