import java.awt.event.MouseListener;
import java.awt.event.MouseEvent;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.FontMetrics;
import java.awt.Graphics;
import java.awt.Toolkit;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import javax.swing.Timer;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.Random;
import javax.swing.ImageIcon;
import javax.swing.JPanel;
import javax.imageio.*;
import java.awt.image.*;
import java.io.*;
import java.util.Scanner;
public class setFace extends JPanel implements Runnable, MouseListener
{
private Dimension d;
int BOARD_WIDTH=1000;
int BOARD_HEIGHT=1000;
int x = 0;
private Thread animator;
public BoardFace()
{
addMouseListener(this);
setFocusable(true);
d = new Dimension(BOARD_WIDTH, BOARD_HEIGHT);
if (animator == null ) {
animator = new Thread(this);
animator.start();
}
setDoubleBuffered(true);
}
public void paint(Graphics g){
super.paint(g);
g.setColor(Color.tan);
g.fillRect(0, 0, d.width, d.height);
Color blue = new Color(0,0,255);
Color lightblue = new Color(132,112,255);
g.setColor(blue);
g.fillOval(100,100, 350, 350);
g.setColor(Color.tan);
g.fillOval(185,175, 75, 50);
g.setColor(Color.tan);
g.fillOval(290,175, 75, 50);
g.setColor(tan);
g.fillOval(205,175, 30, 30);
g.setColor(bltanue);
g.fillOval(310,175, 30, 30);
g.setColor(Color.black);
g.fillOval(210,175, 20, 20);
g.setColor(Color.black);
g.fillOval(315,175, 20, 20);
Color mouth = new Color(235, 93, 102);
g.setColor(lip);
g.fillOval(190,275, 175, 125);
g.setColor(blue);
g.fillOval(190,250, 175, 125);
g.setColor(Color.black);
g.fillOval(100,100, 75, 75);
g.fillOval(140,70, 75, 75);
g.fillOval(180,55, 75, 75);
g.fillOval(220,55, 75, 75);
g.fillOval(260,60, 75, 75);
g.fillOval(300,80, 75, 75);
g.fillOval(340,100, 75, 75);
g.fillOval(380,110, 75, 75);
g.setColor(Color.black);
g.fillOval(275,280,10, 10);
try {
BufferedImage img = ImageIO.read(this.getClass().getResource("nicelook.png"));
g.drawImage(img,200,210,null);
} catch (IOException e) {
System.out.println("Image could not be read");
}
g.setFont (new Font("TimesRoman", Font.PLAIN, 100));
g.drawString("Keep Smiling" , 20, 600);
Toolkit.getDefaultToolkit().sync();
g.dispose();
}
public void run() {
long beforeTime, timeDiff, sleep;
beforeTime = System.currentTimeMillis();
int animationDelay = 500;
long time =
System.currentTimeMillis();
while (true) {//infinite loop
// spriteManager.update();
repaint();
try {
time += animationDelay;
Thread.sleep(Math.max(0,time -
System.currentTimeMillis()));
}catch (InterruptedException e) {
System.out.println(e);
}//end catch
}//end while loop
}//end of run
public void mousePressed(MouseEvent e) {
int x = e.getX();
int y = e.getY();
}
public void mouseReleased(MouseEvent e) {
}
public void mouseEntered(MouseEvent e) {
}
public void mouseExited(MouseEvent e) {
}
public void mouseClicked(MouseEvent e) {
}
}//end of class
Be the first to comment
You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.