This week only. Pastebin PRO Accounts Christmas Special! Don't miss out!Want more features on Pastebin? Sign Up, it's FREE!
Guest

Applet Problems

By: a guest on Mar 20th, 2013  |  syntax: None  |  size: 0.88 KB  |  views: 54  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. import java.applet.*;
  2. import java.awt.*;
  3. import java.awt.event.KeyEvent;
  4. import java.awt.event.KeyListener;
  5. public class PrimarySC extends Applet implements Runnable, KeyListener {
  6.         private static final long serialVersionUID = 1L;
  7.         public void init() {
  8.                 setSize(400,400);
  9.                 setBackground(Color.white);
  10.         }
  11.         public void start() {
  12.                 Thread th = new Thread(this);
  13.                  th.start();
  14.         }
  15.         public void stop() {
  16.         }
  17.         public void run() {
  18.                 Thread.currentThread().setPriority(Thread.MIN_PRIORITY);
  19.                 while(true) {
  20.                        
  21.                         repaint();
  22.                           try {
  23.                             Thread.sleep(20);
  24.                           } catch (InterruptedException ex) {
  25.                           }
  26.                 }
  27.         }
  28.         public void paint (Graphics g) {
  29.                 g.setColor(Color.gray);
  30.                 g.fillRect(10, 400, 30, 100);
  31.         }
  32.         public void keyPressed(KeyEvent e) {
  33.                
  34.         }
  35.         public void keyReleased(KeyEvent e) {
  36.                
  37.         }
  38.         public void keyTyped(KeyEvent e) {
  39.                 int c = e.getKeyChar();
  40.         }
  41. }
clone this paste RAW Paste Data