Repository: Atkachuk13/tkachuk-paint
Pull request #1: Paint
Author: login: Atkachuk13
Created: 2025-04-01T15:31:30Z | Merged: 2025-04-02T20:51:43Z

![Screenshot (103)](https://github.com/user-attachments/assets/0a38e5de-0fcb-476a-adda-179336091473)
![Screenshot (104)](https://github.com/user-attachments/assets/8dbfcf53-9f9f-408f-9d30-eb506c5066a1)



Diff:
diff --git a/src/main/java/tkachuk/paint/DrawingComponent.java b/src/main/java/tkachuk/paint/DrawingComponent.java
new file mode 100644
index 0000000..45f4774
--- /dev/null
+++ b/src/main/java/tkachuk/paint/DrawingComponent.java
@@ -0,0 +1,92 @@
+package tkachuk.paint;
+
+import javax.swing.*;
+import java.awt.*;
+import java.awt.image.BufferedImage;
+
+public class DrawingComponent extends JComponent
+{
+    private Color drawColor = Color.BLACK;
+    private final BufferedImage image = new BufferedImage(
+            800, 650, BufferedImage.TYPE_INT_RGB);
+    private int oldx;
+    private int oldy;
+    Point startPoint;
+    Point endPoint;
+
+    public DrawingComponent()
+    {
+        // set the image to all white
+        Graphics g = image.getGraphics();
+        g.setColor(Color.WHITE);
+        g.fillRect(0, 0, image.getWidth(), image.getHeight());
+    }
+
+    public void setOldxy(int oldx, int oldy)
+    {
+        this.oldx = oldx;
+        this.oldy = oldy;
+        repaint();
+    }
+
+    public void setDrawColor(Color drawColor)
+    {
+        this.drawColor = drawColor;
+        repaint();
+    }
+
+    public Color getDrawColor()
+    {
+        return drawColor;
+    }
+
+    public void setStartPoint(Point point)
+    {
+        this.startPoint = point;
+        endPoint = point;
+        repaint();
+    }
+
+
+    @Override
+    protected void paintComponent(Graphics g)
+    {
+        super.paintComponent(g);
+        g.drawImage(image, 0, 0, null);
+
+        if (startPoint != null && endPoint != null)
+        {
+            g.drawLine(startPoint.x, startPoint.y, endPoint.x, endPoint.y);
+        }
+
+    }
+
+    public void drawFromMouse(int x, int y)
+    {
+        Graphics g = image.getGraphics();
+        g.setColor(drawColor);
+        if (oldx != -1 && oldy != -1)
+        {
+            g.drawLine(oldx, oldy, x, y);
+        }
+        oldx = x;
+        oldy = y;
+
+        repaint();  // tells the operating system to recall the whole drawing component
+    }
+
+    public void drawLine(int x1, int y1, int x2, int y2)
+    {
+        Graphics g = image.getGraphics();
+        g.setColor(drawColor);
+        g.drawLine(x1, y1, x2, y2);
+        repaint();
+
+    }
+
+    public void showLine(Point point)
+    {
+        endPoint = point;
+        repaint();
+    }
+}
diff --git a/src/main/java/tkachuk/paint/PaintFrame.java b/src/main/java/tkachuk/paint/PaintFrame.java
new file mode 100644
index 0000000..c87c542
--- /dev/null
+++ b/src/main/java/tkachuk/paint/PaintFrame.java
@@ -0,0 +1,151 @@
+package tkachuk.paint;
+
+import javax.swing.*;
+import java.awt.*;
+import java.awt.event.*;
+
+public class PaintFrame extends JFrame
+{
+    private final DrawingComponent canvas = new DrawingComponent();
+    private boolean pencilPressed = false;
+    private boolean linePressed = false;
+
+    public PaintFrame()
+    {
+        //frame
+        setTitle("Paint Frame");
+        setSize(800, 800);
+        setDefaultCloseOperation(EXIT_ON_CLOSE);
+        setLayout(new BorderLayout());
+
+        //main panel
+        JPanel panel = new JPanel();
+        panel.setLayout(new FlowLayout());
+
+        //sub panel 1
+        JPanel sub1 = new JPanel();
+        sub1.setLayout(new FlowLayout());
+
+        //sub panel 2
+        JPanel sub2 = new JPanel();
+        sub2.setLayout(new FlowLayout());
+
+        // buttons panel 1
+        JButton pencil = new JButton("Pencil");
+        JButton line = new JButton("|");
+
+        sub1.add(pencil);
+        sub1.add(line);
+
+        // colors panel 2
+        JButton colorButton = new JButton("Colors");
+
+        sub2.add(colorButton);
+
+        panel.add(sub1);
+        panel.add(sub2);
+
+        add(canvas, BorderLayout.CENTER);
+        add(panel, BorderLayout.SOUTH);
+
+        pencil.addActionListener(e ->
+        {
+            pencilPressed = true;
+            linePressed = false;
+        });
+
+        line.addActionListener(e ->
+        {
+            pencilPressed = false;
+            linePressed = true;
+        });
+
+        colorButton.addActionListener(e ->
+        {
+            Color newColor = JColorChooser.showDialog(
+                    PaintFrame.this,
+                    "Colors",
+                    canvas.getDrawColor()
+            );
+
+            if (newColor != null)
+            {
+                canvas.setDrawColor(newColor);
+            }
+        });
+
+        canvas.addMouseMotionListener(new MouseMotionListener()
+        {
+            @Override
+            public void mouseDragged(MouseEvent event)
+            {
+                if (pencilPressed)
+                {
+                    canvas.drawFromMouse(event.getX(), event.getY());
+                } else if (linePressed)
+                {
+                    canvas.showLine(event.getPoint());
+                }
+            }
+
+            @Override
+            public void mouseMoved(MouseEvent event)
+            {
+
+            }
+        });
+
+        canvas.addMouseListener(new MouseListener()
+        {
+            private Point start;
+
+            @Override
+            public void mouseClicked(MouseEvent event)
+            {
+
+            }
+
+            @Override
+            public void mousePressed(MouseEvent event)
+            {
+                if (linePressed)
+                {
+                    start = event.getPoint();
+                    canvas.setStartPoint(start);
+                } else if (pencilPressed)
+                {
+                    canvas.setOldxy(event.getX(), event.getY());
+                }
+
+            }
+
+            @Override
+            public void mouseReleased(MouseEvent event)
+            {
+                if (linePressed)
+                {
+                    canvas.drawLine(start.x, start.y, event.getX(), event.getY());
+                }
+            }
+
+            @Override
+            public void mouseEntered(MouseEvent e)
+            {
+
+            }
+
+            @Override
+            public void mouseExited(MouseEvent e)
+            {
+
+            }
+        });
+
+    }
+
+    public static void main(String[] args)
+    {
+        PaintFrame frame = new PaintFrame();
+        frame.setVisible(true);
+    }
+}


Reviews:
user: login: github-actions[bot]
state: COMMENTED
author_association: NONE
submitted_at: 2025-04-01T15:32:02Z
user: login: andrewoid
state: COMMENTED
author_association: NONE
submitted_at: 2025-04-01T15:35:18Z
user: login: andrewoid
state: COMMENTED
author_association: NONE
submitted_at: 2025-04-01T21:24:00Z
user: login: andrewoid
state: APPROVED
author_association: NONE
submitted_at: 2025-04-02T20:40:11Z

Review comments:
diff_hunk: @@ -0,0 +1,64 @@
+package tkachuk.paint;
+
+import javax.swing.*;
+import java.awt.*;
+import java.awt.image.BufferedImage;
+import java.util.List;
+
+public class DrawingComponent extends JComponent
+{
+private Color drawColor = Color.BLACK;
+    private final BufferedImage image = new BufferedImage(
+            800,650,
path: src/main/java/tkachuk/paint/DrawingComponent.java
user: login: github-actions[bot]
body: ⚠️ **[checkstyle]** <com.puppycrawl.tools.checkstyle.checks.whitespace.WhitespaceAfterCheck> <sub>reported by [reviewdog](https://github.com/reviewdog/reviewdog) :dog:</sub><br>',' is not followed by whitespace.
created_at: 2025-04-01T15:32:00Z
author_association: NONE
diff_hunk: @@ -0,0 +1,64 @@
+package tkachuk.paint;
+
+import javax.swing.*;
+import java.awt.*;
+import java.awt.image.BufferedImage;
+import java.util.List;
+
+public class DrawingComponent extends JComponent
+{
+private Color drawColor = Color.BLACK;
+    private final BufferedImage image = new BufferedImage(
+            800,650,
+            BufferedImage.TYPE_INT_RGB);
+    private  int oldx;
+    private int oldy;
+
+    public void setOldxy(int oldx, int oldy)
+    {
+        this.oldx = oldx;
+        this.oldy = oldy;
+        repaint();
+    }
+
+    public void setDrawColor(Color drawColor)
+    {
+        this.drawColor = drawColor;
+        repaint();
+    }
+    public DrawingComponent()
path: src/main/java/tkachuk/paint/DrawingComponent.java
user: login: github-actions[bot]
body: ⚠️ **[checkstyle]** <com.puppycrawl.tools.checkstyle.checks.whitespace.EmptyLineSeparatorCheck> <sub>reported by [reviewdog](https://github.com/reviewdog/reviewdog) :dog:</sub><br>'CTOR_DEF' should be separated from previous line.
created_at: 2025-04-01T15:32:00Z
author_association: NONE
diff_hunk: @@ -0,0 +1,64 @@
+package tkachuk.paint;
+
+import javax.swing.*;
+import java.awt.*;
+import java.awt.image.BufferedImage;
+import java.util.List;
+
+public class DrawingComponent extends JComponent
+{
+private Color drawColor = Color.BLACK;
+    private final BufferedImage image = new BufferedImage(
+            800,650,
+            BufferedImage.TYPE_INT_RGB);
+    private  int oldx;
+    private int oldy;
+
+    public void setOldxy(int oldx, int oldy)
+    {
+        this.oldx = oldx;
+        this.oldy = oldy;
+        repaint();
+    }
+
+    public void setDrawColor(Color drawColor)
+    {
+        this.drawColor = drawColor;
+        repaint();
+    }
+    public DrawingComponent()
+    {
+        // set the image to all white
+        Graphics g = image.getGraphics();
+        g.setColor(Color.WHITE);
+        g.fillRect(0,0,image.getWidth(),image.getHeight());
path: src/main/java/tkachuk/paint/DrawingComponent.java
user: login: github-actions[bot]
body: ⚠️ **[checkstyle]** <com.puppycrawl.tools.checkstyle.checks.whitespace.WhitespaceAfterCheck> <sub>reported by [reviewdog](https://github.com/reviewdog/reviewdog) :dog:</sub><br>',' is not followed by whitespace.
created_at: 2025-04-01T15:32:00Z
author_association: NONE
diff_hunk: @@ -0,0 +1,64 @@
+package tkachuk.paint;
+
+import javax.swing.*;
+import java.awt.*;
+import java.awt.image.BufferedImage;
+import java.util.List;
+
+public class DrawingComponent extends JComponent
+{
+private Color drawColor = Color.BLACK;
+    private final BufferedImage image = new BufferedImage(
+            800,650,
+            BufferedImage.TYPE_INT_RGB);
+    private  int oldx;
+    private int oldy;
+
+    public void setOldxy(int oldx, int oldy)
+    {
+        this.oldx = oldx;
+        this.oldy = oldy;
+        repaint();
+    }
+
+    public void setDrawColor(Color drawColor)
+    {
+        this.drawColor = drawColor;
+        repaint();
+    }
+    public DrawingComponent()
+    {
+        // set the image to all white
+        Graphics g = image.getGraphics();
+        g.setColor(Color.WHITE);
+        g.fillRect(0,0,image.getWidth(),image.getHeight());
path: src/main/java/tkachuk/paint/DrawingComponent.java
user: login: github-actions[bot]
body: ⚠️ **[checkstyle]** <com.puppycrawl.tools.checkstyle.checks.whitespace.WhitespaceAfterCheck> <sub>reported by [reviewdog](https://github.com/reviewdog/reviewdog) :dog:</sub><br>',' is not followed by whitespace.
created_at: 2025-04-01T15:32:00Z
author_association: NONE
diff_hunk: @@ -0,0 +1,64 @@
+package tkachuk.paint;
+
+import javax.swing.*;
+import java.awt.*;
+import java.awt.image.BufferedImage;
+import java.util.List;
+
+public class DrawingComponent extends JComponent
+{
+private Color drawColor = Color.BLACK;
+    private final BufferedImage image = new BufferedImage(
+            800,650,
+            BufferedImage.TYPE_INT_RGB);
+    private  int oldx;
+    private int oldy;
+
+    public void setOldxy(int oldx, int oldy)
+    {
+        this.oldx = oldx;
+        this.oldy = oldy;
+        repaint();
+    }
+
+    public void setDrawColor(Color drawColor)
+    {
+        this.drawColor = drawColor;
+        repaint();
+    }
+    public DrawingComponent()
+    {
+        // set the image to all white
+        Graphics g = image.getGraphics();
+        g.setColor(Color.WHITE);
+        g.fillRect(0,0,image.getWidth(),image.getHeight());
path: src/main/java/tkachuk/paint/DrawingComponent.java
user: login: github-actions[bot]
body: ⚠️ **[checkstyle]** <com.puppycrawl.tools.checkstyle.checks.whitespace.WhitespaceAfterCheck> <sub>reported by [reviewdog](https://github.com/reviewdog/reviewdog) :dog:</sub><br>',' is not followed by whitespace.
created_at: 2025-04-01T15:32:00Z
author_association: NONE
diff_hunk: @@ -0,0 +1,64 @@
+package tkachuk.paint;
+
+import javax.swing.*;
+import java.awt.*;
+import java.awt.image.BufferedImage;
+import java.util.List;
+
+public class DrawingComponent extends JComponent
+{
+private Color drawColor = Color.BLACK;
+    private final BufferedImage image = new BufferedImage(
+            800,650,
+            BufferedImage.TYPE_INT_RGB);
+    private  int oldx;
+    private int oldy;
+
+    public void setOldxy(int oldx, int oldy)
+    {
+        this.oldx = oldx;
+        this.oldy = oldy;
+        repaint();
+    }
+
+    public void setDrawColor(Color drawColor)
+    {
+        this.drawColor = drawColor;
+        repaint();
+    }
+    public DrawingComponent()
+    {
+        // set the image to all white
+        Graphics g = image.getGraphics();
+        g.setColor(Color.WHITE);
+        g.fillRect(0,0,image.getWidth(),image.getHeight());
+    }
+
+    @Override
+    protected void paintComponent(Graphics g)
+    {
+        super.paintComponent(g);
+
+        g.drawImage(image,0,0,null);
path: src/main/java/tkachuk/paint/DrawingComponent.java
user: login: github-actions[bot]
body: ⚠️ **[checkstyle]** <com.puppycrawl.tools.checkstyle.checks.whitespace.WhitespaceAfterCheck> <sub>reported by [reviewdog](https://github.com/reviewdog/reviewdog) :dog:</sub><br>',' is not followed by whitespace.
created_at: 2025-04-01T15:32:00Z
author_association: NONE
diff_hunk: @@ -0,0 +1,64 @@
+package tkachuk.paint;
+
+import javax.swing.*;
+import java.awt.*;
+import java.awt.image.BufferedImage;
+import java.util.List;
+
+public class DrawingComponent extends JComponent
+{
+private Color drawColor = Color.BLACK;
+    private final BufferedImage image = new BufferedImage(
+            800,650,
+            BufferedImage.TYPE_INT_RGB);
+    private  int oldx;
+    private int oldy;
+
+    public void setOldxy(int oldx, int oldy)
+    {
+        this.oldx = oldx;
+        this.oldy = oldy;
+        repaint();
+    }
+
+    public void setDrawColor(Color drawColor)
+    {
+        this.drawColor = drawColor;
+        repaint();
+    }
+    public DrawingComponent()
+    {
+        // set the image to all white
+        Graphics g = image.getGraphics();
+        g.setColor(Color.WHITE);
+        g.fillRect(0,0,image.getWidth(),image.getHeight());
+    }
+
+    @Override
+    protected void paintComponent(Graphics g)
+    {
+        super.paintComponent(g);
+
+        g.drawImage(image,0,0,null);
path: src/main/java/tkachuk/paint/DrawingComponent.java
user: login: github-actions[bot]
body: ⚠️ **[checkstyle]** <com.puppycrawl.tools.checkstyle.checks.whitespace.WhitespaceAfterCheck> <sub>reported by [reviewdog](https://github.com/reviewdog/reviewdog) :dog:</sub><br>',' is not followed by whitespace.
created_at: 2025-04-01T15:32:01Z
author_association: NONE
diff_hunk: @@ -0,0 +1,64 @@
+package tkachuk.paint;
+
+import javax.swing.*;
+import java.awt.*;
+import java.awt.image.BufferedImage;
+import java.util.List;
+
+public class DrawingComponent extends JComponent
+{
+private Color drawColor = Color.BLACK;
+    private final BufferedImage image = new BufferedImage(
+            800,650,
+            BufferedImage.TYPE_INT_RGB);
+    private  int oldx;
+    private int oldy;
+
+    public void setOldxy(int oldx, int oldy)
+    {
+        this.oldx = oldx;
+        this.oldy = oldy;
+        repaint();
+    }
+
+    public void setDrawColor(Color drawColor)
+    {
+        this.drawColor = drawColor;
+        repaint();
+    }
+    public DrawingComponent()
+    {
+        // set the image to all white
+        Graphics g = image.getGraphics();
+        g.setColor(Color.WHITE);
+        g.fillRect(0,0,image.getWidth(),image.getHeight());
+    }
+
+    @Override
+    protected void paintComponent(Graphics g)
+    {
+        super.paintComponent(g);
+
+        g.drawImage(image,0,0,null);
path: src/main/java/tkachuk/paint/DrawingComponent.java
user: login: github-actions[bot]
body: ⚠️ **[checkstyle]** <com.puppycrawl.tools.checkstyle.checks.whitespace.WhitespaceAfterCheck> <sub>reported by [reviewdog](https://github.com/reviewdog/reviewdog) :dog:</sub><br>',' is not followed by whitespace.
created_at: 2025-04-01T15:32:01Z
author_association: NONE
diff_hunk: @@ -0,0 +1,64 @@
+package tkachuk.paint;
+
+import javax.swing.*;
+import java.awt.*;
+import java.awt.image.BufferedImage;
+import java.util.List;
+
+public class DrawingComponent extends JComponent
+{
+private Color drawColor = Color.BLACK;
+    private final BufferedImage image = new BufferedImage(
+            800,650,
+            BufferedImage.TYPE_INT_RGB);
+    private  int oldx;
+    private int oldy;
+
+    public void setOldxy(int oldx, int oldy)
+    {
+        this.oldx = oldx;
+        this.oldy = oldy;
+        repaint();
+    }
+
+    public void setDrawColor(Color drawColor)
+    {
+        this.drawColor = drawColor;
+        repaint();
+    }
+    public DrawingComponent()
+    {
+        // set the image to all white
+        Graphics g = image.getGraphics();
+        g.setColor(Color.WHITE);
+        g.fillRect(0,0,image.getWidth(),image.getHeight());
+    }
+
+    @Override
+    protected void paintComponent(Graphics g)
+    {
+        super.paintComponent(g);
+
+        g.drawImage(image,0,0,null);
+
+    }
+
+    public void drawFromMouse(int x, int y)
+    {
+        Graphics g = image.getGraphics();
+        g.setColor(drawColor);
+        if(oldx != -1 && oldy != -1)
path: src/main/java/tkachuk/paint/DrawingComponent.java
user: login: github-actions[bot]
body: ⚠️ **[checkstyle]** <com.puppycrawl.tools.checkstyle.checks.whitespace.WhitespaceAfterCheck> <sub>reported by [reviewdog](https://github.com/reviewdog/reviewdog) :dog:</sub><br>'if' is not followed by whitespace.
created_at: 2025-04-01T15:32:01Z
author_association: NONE
diff_hunk: @@ -0,0 +1,64 @@
+package tkachuk.paint;
+
+import javax.swing.*;
+import java.awt.*;
+import java.awt.image.BufferedImage;
+import java.util.List;
+
+public class DrawingComponent extends JComponent
+{
+private Color drawColor = Color.BLACK;
+    private final BufferedImage image = new BufferedImage(
+            800,650,
+            BufferedImage.TYPE_INT_RGB);
+    private  int oldx;
+    private int oldy;
+
+    public void setOldxy(int oldx, int oldy)
+    {
+        this.oldx = oldx;
+        this.oldy = oldy;
+        repaint();
+    }
+
+    public void setDrawColor(Color drawColor)
+    {
+        this.drawColor = drawColor;
+        repaint();
+    }
+    public DrawingComponent()
+    {
+        // set the image to all white
+        Graphics g = image.getGraphics();
+        g.setColor(Color.WHITE);
+        g.fillRect(0,0,image.getWidth(),image.getHeight());
+    }
+
+    @Override
+    protected void paintComponent(Graphics g)
+    {
+        super.paintComponent(g);
+
+        g.drawImage(image,0,0,null);
+
+    }
+
+    public void drawFromMouse(int x, int y)
+    {
+        Graphics g = image.getGraphics();
+        g.setColor(drawColor);
+        if(oldx != -1 && oldy != -1)
path: src/main/java/tkachuk/paint/DrawingComponent.java
user: login: github-actions[bot]
body: ⚠️ **[checkstyle]** <com.puppycrawl.tools.checkstyle.checks.whitespace.WhitespaceAroundCheck> <sub>reported by [reviewdog](https://github.com/reviewdog/reviewdog) :dog:</sub><br>WhitespaceAround: 'if' is not followed by whitespace. Empty blocks may only be represented as {} when not part of a multi-block statement (4.1.3)
created_at: 2025-04-01T15:32:01Z
author_association: NONE
diff_hunk: @@ -0,0 +1,64 @@
+package tkachuk.paint;
+
+import javax.swing.*;
+import java.awt.*;
+import java.awt.image.BufferedImage;
+import java.util.List;
+
+public class DrawingComponent extends JComponent
+{
+private Color drawColor = Color.BLACK;
+    private final BufferedImage image = new BufferedImage(
+            800,650,
+            BufferedImage.TYPE_INT_RGB);
+    private  int oldx;
+    private int oldy;
+
+    public void setOldxy(int oldx, int oldy)
+    {
+        this.oldx = oldx;
+        this.oldy = oldy;
+        repaint();
+    }
+
+    public void setDrawColor(Color drawColor)
+    {
+        this.drawColor = drawColor;
+        repaint();
+    }
+    public DrawingComponent()
+    {
+        // set the image to all white
+        Graphics g = image.getGraphics();
+        g.setColor(Color.WHITE);
+        g.fillRect(0,0,image.getWidth(),image.getHeight());
+    }
+
+    @Override
+    protected void paintComponent(Graphics g)
+    {
+        super.paintComponent(g);
+
+        g.drawImage(image,0,0,null);
+
+    }
+
+    public void drawFromMouse(int x, int y)
+    {
+        Graphics g = image.getGraphics();
+        g.setColor(drawColor);
+        if(oldx != -1 && oldy != -1)
+        {
+            g.drawLine(oldx,oldy,x,y);
path: src/main/java/tkachuk/paint/DrawingComponent.java
user: login: github-actions[bot]
body: ⚠️ **[checkstyle]** <com.puppycrawl.tools.checkstyle.checks.whitespace.WhitespaceAfterCheck> <sub>reported by [reviewdog](https://github.com/reviewdog/reviewdog) :dog:</sub><br>',' is not followed by whitespace.
created_at: 2025-04-01T15:32:01Z
author_association: NONE
diff_hunk: @@ -0,0 +1,64 @@
+package tkachuk.paint;
+
+import javax.swing.*;
+import java.awt.*;
+import java.awt.image.BufferedImage;
+import java.util.List;
+
+public class DrawingComponent extends JComponent
+{
+private Color drawColor = Color.BLACK;
+    private final BufferedImage image = new BufferedImage(
+            800,650,
+            BufferedImage.TYPE_INT_RGB);
+    private  int oldx;
+    private int oldy;
+
+    public void setOldxy(int oldx, int oldy)
+    {
+        this.oldx = oldx;
+        this.oldy = oldy;
+        repaint();
+    }
+
+    public void setDrawColor(Color drawColor)
+    {
+        this.drawColor = drawColor;
+        repaint();
+    }
+    public DrawingComponent()
+    {
+        // set the image to all white
+        Graphics g = image.getGraphics();
+        g.setColor(Color.WHITE);
+        g.fillRect(0,0,image.getWidth(),image.getHeight());
+    }
+
+    @Override
+    protected void paintComponent(Graphics g)
+    {
+        super.paintComponent(g);
+
+        g.drawImage(image,0,0,null);
+
+    }
+
+    public void drawFromMouse(int x, int y)
+    {
+        Graphics g = image.getGraphics();
+        g.setColor(drawColor);
+        if(oldx != -1 && oldy != -1)
+        {
+            g.drawLine(oldx,oldy,x,y);
path: src/main/java/tkachuk/paint/DrawingComponent.java
user: login: github-actions[bot]
body: ⚠️ **[checkstyle]** <com.puppycrawl.tools.checkstyle.checks.whitespace.WhitespaceAfterCheck> <sub>reported by [reviewdog](https://github.com/reviewdog/reviewdog) :dog:</sub><br>',' is not followed by whitespace.
created_at: 2025-04-01T15:32:01Z
author_association: NONE
diff_hunk: @@ -0,0 +1,64 @@
+package tkachuk.paint;
+
+import javax.swing.*;
+import java.awt.*;
+import java.awt.image.BufferedImage;
+import java.util.List;
+
+public class DrawingComponent extends JComponent
+{
+private Color drawColor = Color.BLACK;
+    private final BufferedImage image = new BufferedImage(
+            800,650,
+            BufferedImage.TYPE_INT_RGB);
+    private  int oldx;
+    private int oldy;
+
+    public void setOldxy(int oldx, int oldy)
+    {
+        this.oldx = oldx;
+        this.oldy = oldy;
+        repaint();
+    }
+
+    public void setDrawColor(Color drawColor)
+    {
+        this.drawColor = drawColor;
+        repaint();
+    }
+    public DrawingComponent()
+    {
+        // set the image to all white
+        Graphics g = image.getGraphics();
+        g.setColor(Color.WHITE);
+        g.fillRect(0,0,image.getWidth(),image.getHeight());
+    }
+
+    @Override
+    protected void paintComponent(Graphics g)
+    {
+        super.paintComponent(g);
+
+        g.drawImage(image,0,0,null);
+
+    }
+
+    public void drawFromMouse(int x, int y)
+    {
+        Graphics g = image.getGraphics();
+        g.setColor(drawColor);
+        if(oldx != -1 && oldy != -1)
+        {
+            g.drawLine(oldx,oldy,x,y);
path: src/main/java/tkachuk/paint/DrawingComponent.java
user: login: github-actions[bot]
body: ⚠️ **[checkstyle]** <com.puppycrawl.tools.checkstyle.checks.whitespace.WhitespaceAfterCheck> <sub>reported by [reviewdog](https://github.com/reviewdog/reviewdog) :dog:</sub><br>',' is not followed by whitespace.
created_at: 2025-04-01T15:32:01Z
author_association: NONE
diff_hunk: @@ -0,0 +1,124 @@
+package tkachuk.paint;
+
+import javax.swing.*;
+import java.awt.*;
+import java.awt.event.*;
+
+public class PaintFrame extends JFrame
+{
+    private final DrawingComponent canvas = new DrawingComponent();
+
+    public PaintFrame()
+    {
+        //frame
+        setTitle("Paint Frame");
+        setSize(800,800 );
path: src/main/java/tkachuk/paint/PaintFrame.java
user: login: github-actions[bot]
body: ⚠️ **[checkstyle]** <com.puppycrawl.tools.checkstyle.checks.whitespace.WhitespaceAfterCheck> <sub>reported by [reviewdog](https://github.com/reviewdog/reviewdog) :dog:</sub><br>',' is not followed by whitespace.
created_at: 2025-04-01T15:32:01Z
author_association: NONE
diff_hunk: @@ -0,0 +1,124 @@
+package tkachuk.paint;
+
+import javax.swing.*;
+import java.awt.*;
+import java.awt.event.*;
+
+public class PaintFrame extends JFrame
+{
+    private final DrawingComponent canvas = new DrawingComponent();
+
+    public PaintFrame()
+    {
+        //frame
+        setTitle("Paint Frame");
+        setSize(800,800 );
path: src/main/java/tkachuk/paint/PaintFrame.java
user: login: github-actions[bot]
body: ⚠️ **[checkstyle]** <com.puppycrawl.tools.checkstyle.checks.whitespace.ParenPadCheck> <sub>reported by [reviewdog](https://github.com/reviewdog/reviewdog) :dog:</sub><br>')' is preceded with whitespace.
created_at: 2025-04-01T15:32:02Z
author_association: NONE
diff_hunk: @@ -0,0 +1,124 @@
+package tkachuk.paint;
+
+import javax.swing.*;
+import java.awt.*;
+import java.awt.event.*;
+
+public class PaintFrame extends JFrame
+{
+    private final DrawingComponent canvas = new DrawingComponent();
+
+    public PaintFrame()
+    {
+        //frame
+        setTitle("Paint Frame");
+        setSize(800,800 );
+        setDefaultCloseOperation(EXIT_ON_CLOSE);
+        setLayout(new BorderLayout());
+
+        //main panel
+        JPanel panel = new JPanel();
+        panel.setLayout(new FlowLayout());
+
+        //sub panel 1
+        JPanel sub1 = new JPanel();
+        sub1.setLayout(new FlowLayout());
+
+        //sub panel 2
+        JPanel sub2 = new JPanel();
+        sub2.setLayout(new FlowLayout());
+
+        // buttons panel 1
+        JButton pencil = new JButton("Pencil");
path: src/main/java/tkachuk/paint/PaintFrame.java
user: login: github-actions[bot]
body: ⚠️ **[checkstyle]** <com.puppycrawl.tools.checkstyle.checks.coding.VariableDeclarationUsageDistanceCheck> <sub>reported by [reviewdog](https://github.com/reviewdog/reviewdog) :dog:</sub><br>Distance between variable 'pencil' declaration and its first usage is 6, but allowed 3.  Consider making that variable final if you still need to store its value in advance (before method calls that might have side effects on the original value).
created_at: 2025-04-01T15:32:02Z
author_association: NONE
diff_hunk: @@ -0,0 +1,124 @@
+package tkachuk.paint;
+
+import javax.swing.*;
+import java.awt.*;
+import java.awt.event.*;
+
+public class PaintFrame extends JFrame
+{
+    private final DrawingComponent canvas = new DrawingComponent();
+
+    public PaintFrame()
+    {
+        //frame
+        setTitle("Paint Frame");
+        setSize(800,800 );
+        setDefaultCloseOperation(EXIT_ON_CLOSE);
+        setLayout(new BorderLayout());
+
+        //main panel
+        JPanel panel = new JPanel();
+        panel.setLayout(new FlowLayout());
+
+        //sub panel 1
+        JPanel sub1 = new JPanel();
+        sub1.setLayout(new FlowLayout());
+
+        //sub panel 2
+        JPanel sub2 = new JPanel();
+        sub2.setLayout(new FlowLayout());
+
+        // buttons panel 1
+        JButton pencil = new JButton("Pencil");
+        JButton line = new JButton("|");
path: src/main/java/tkachuk/paint/PaintFrame.java
user: login: github-actions[bot]
body: ⚠️ **[checkstyle]** <com.puppycrawl.tools.checkstyle.checks.coding.VariableDeclarationUsageDistanceCheck> <sub>reported by [reviewdog](https://github.com/reviewdog/reviewdog) :dog:</sub><br>Distance between variable 'line' declaration and its first usage is 7, but allowed 3.  Consider making that variable final if you still need to store its value in advance (before method calls that might have side effects on the original value).
created_at: 2025-04-01T15:32:02Z
author_association: NONE
diff_hunk: @@ -0,0 +1,64 @@
+package tkachuk.paint;
+
+import javax.swing.*;
+import java.awt.*;
+import java.awt.image.BufferedImage;
+import java.util.List;
+
+public class DrawingComponent extends JComponent
+{
+private Color drawColor = Color.BLACK;
+    private final BufferedImage image = new BufferedImage(
+            800,650,
+            BufferedImage.TYPE_INT_RGB);
+    private  int oldx;
+    private int oldy;
+
+    public void setOldxy(int oldx, int oldy)
+    {
+        this.oldx = oldx;
+        this.oldy = oldy;
+        repaint();
+    }
+
+    public void setDrawColor(Color drawColor)
+    {
+        this.drawColor = drawColor;
+        repaint();
+    }
+    public DrawingComponent()
path: src/main/java/tkachuk/paint/DrawingComponent.java
user: login: andrewoid
body: constructor should go after the member variables but BEFORE the methods.
created_at: 2025-04-01T15:34:52Z
author_association: NONE
diff_hunk: @@ -0,0 +1,154 @@
+package tkachuk.paint;
+
+import javax.swing.*;
+import java.awt.*;
+import java.awt.event.*;
+
+public class PaintFrame extends JFrame
+{
+    private final DrawingComponent canvas = new DrawingComponent();
+    private boolean pencilPressed = false;
+    private boolean linePressed = false;
+
+    public PaintFrame()
+    {
+        //frame
+        setTitle("Paint Frame");
+        setSize(800, 800);
+        setDefaultCloseOperation(EXIT_ON_CLOSE);
+        setLayout(new BorderLayout());
+
+        //main panel
+        JPanel panel = new JPanel();
+        panel.setLayout(new FlowLayout());
+
+        //sub panel 1
+        JPanel sub1 = new JPanel();
+        sub1.setLayout(new FlowLayout());
+
+        //sub panel 2
+        JPanel sub2 = new JPanel();
+        sub2.setLayout(new FlowLayout());
+
+        // buttons panel 1
+        JButton pencil = new JButton("Pencil");
+        JButton line = new JButton("|");
+
+        sub1.add(pencil);
+        sub1.add(line);
+
+        // buttons panel 2
+        JButton green = new JButton();
+        green.setBackground(Color.GREEN);
+        JButton blue = new JButton();
+        blue.setBackground(Color.BLUE);
+        JButton red = new JButton();
+        red.setBackground(Color.RED);
+        JButton magenta = new JButton();
+        magenta.setBackground(Color.MAGENTA);
+        JButton black = new JButton();
+        black.setBackground(Color.BLACK);
path: src/main/java/tkachuk/paint/PaintFrame.java
user: login: andrewoid
body: You were supposed to use JColorChooser.
created_at: 2025-04-01T21:23:59Z
author_association: NONE

PR comments:
user: login: andrewoid
created_at: 2025-04-01T15:34:21Z
body: add a screenshot
author_association: NONE
user: login: andrewoid
created_at: 2025-04-01T21:23:24Z
body: You need to have a preview of the line that is going to be drawn before you release the mouse button.
author_association: NONE