document.write('
Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. import java.awt.*;
  2. import java.awt.event.ActionEvent;
  3. import java.awt.event.ActionListener;
  4. import javax.swing.*;
  5.  
  6. @SuppressWarnings("serial")
  7. public class Applet2017a extends JApplet implements ActionListener {
  8.     int x = 0, y = 0;
  9.     JPanel drawPanel = new JPanel() {
  10.         @Override
  11.         public void paint(Graphics g) {
  12.             g.clearRect(0, 0, this.getWidth(), this.getHeight());
  13.             g.drawLine(x, y, x + 100, y + 100);
  14.         }
  15.     };
  16.     JPanel controlPanel = new JPanel();
  17.     JButton button = new JButton("Press me");
  18.    
  19.     {
  20.         this.setLayout(new GridLayout(1, 2));
  21.         this.add(drawPanel, BorderLayout.EAST);
  22.         this.add(controlPanel, BorderLayout.WEST);
  23.         controlPanel.add(button);
  24.         button.addActionListener(this);
  25.     }
  26.  
  27.     @Override
  28.     public void actionPerformed(ActionEvent e) {
  29.         x += 10;
  30.         drawPanel.repaint();
  31.     }
  32. }
');