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.  *   Kelas tool button untuk menambahkan aturan gerakan mouse yang sudah dibuat di drawing panel tadi
  8.  *   ke dalam setiap tool yang ada
  9.  */
  10.  
  11. import javax.swing.*;
  12. import java.awt.*;
  13. import java.awt.event.ActionEvent;
  14. import java.awt.event.ActionListener;
  15.  
  16. public class ToolButton extends JButton implements ActionListener
  17. {
  18.  
  19.     public JLabel label;
  20.     public Tool tool;
  21.  
  22.     public ToolButton(Icon icon, Tool tool)
  23.     {
  24.         label = new JLabel(icon);
  25.         setLayout(new BorderLayout());
  26.         add(label);
  27.         this.tool = tool;
  28.         addActionListener(this);
  29.     }
  30.  
  31.     public void paintComponent(Graphics g)
  32.     {
  33.         super.paintComponent(g);
  34.     }
  35.  
  36.     public void actionPerformed(ActionEvent event)
  37.     {
  38.         Main.paint.drawingPanel.currentTool = tool;
  39.         Main.paint.repaint();
  40.     }
  41. }
  42.  
');