document.write('
Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. /**
  2.  *   JAVA DRAWING APP
  3.  *   Author  : Johnivan Aldo S
  4.  *           : Yeremia Dhyan L
  5.  *   Version : 7 Januari 2021
  6.  */
  7.  
  8. import javax.swing.*;
  9. import java.awt.*;
  10.  
  11. public class StrokePanel extends JPanel
  12. {
  13.  
  14.     public StrokePanel()
  15.     {
  16.         setPreferredSize(new Dimension(84, 84));   //set size of the stroke panel
  17.     }
  18.  
  19.     public void paintComponent(Graphics g)   //overrides method in JComponent and paints the stroke
  20.     {
  21.         g.setColor(Main.paint.drawingPanel.currentToolDetails.getColor());
  22.         g.fillRect(getWidth() / 2 - Main.paint.drawingPanel.currentToolDetails.getStrokeWidth() / 2,
  23.                 getHeight() / 2 - Main.paint.drawingPanel.currentToolDetails.getStrokeWidth() / 2,
  24.                 Main.paint.drawingPanel.currentToolDetails.getStrokeWidth(),
  25.                 Main.paint.drawingPanel.currentToolDetails.getStrokeWidth());
  26.         g.setColor(Color.black);
  27.         g.drawRect(getWidth() / 2 - Main.paint.drawingPanel.currentToolDetails.getStrokeWidth() / 2,
  28.                 getHeight() / 2 - Main.paint.drawingPanel.currentToolDetails.getStrokeWidth() / 2,
  29.                 Main.paint.drawingPanel.currentToolDetails.getStrokeWidth(),
  30.                 Main.paint.drawingPanel.currentToolDetails.getStrokeWidth());
  31.   }
  32. }
  33.  
');