Advertisement
Guest User

Untitled

a guest
Apr 30th, 2016
157
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.50 KB | None | 0 0
  1. package me.Joey402;
  2. import java.awt.Graphics;
  3. import java.awt.Graphics2D;
  4. import java.awt.RenderingHints;
  5. import java.awt.image.BufferedImage;
  6. import java.io.File;
  7. import java.io.IOException;
  8. import javax.imageio.ImageIO;
  9. import javax.swing.JFrame;
  10. public class StickFrame extends JFrame{
  11. /**
  12. *
  13. */
  14. private static final long serialVersionUID = 1L;
  15. public static BufferedImage bg,stick1,stick2,offscreen;
  16. public static boolean left1, right1, left2, right2,repaint,repaint2;
  17. public static int stickx1,stickx2;
  18. public static Graphics d;
  19. public static void main(String[] args){
  20. File file = new File("bg.png");
  21. try{
  22. bg = ImageIO.read(file);
  23.  
  24. } catch (IOException e){
  25. e.printStackTrace();
  26. }
  27. new StickFrame();
  28. }
  29. public StickFrame(){
  30. init();
  31. }
  32. public void init(){
  33. setSize(1100,900);
  34. setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  35. setLocationRelativeTo(null);
  36. setVisible(true);
  37. offscreen = (BufferedImage) createImage(1100,900);
  38. d = offscreen.getGraphics();
  39. Thread th = new Thread();
  40. th.start();
  41. }
  42. public void paint(Graphics g){
  43. super.paint(g);
  44. Graphics2D g2 = (Graphics2D) g;
  45. g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
  46. // Background
  47. g2.drawImage(bg, 0, 0, this);
  48. g2.drawOval(stickx1, 610, 50, 50);
  49. }
  50. public void update(Graphics g){
  51. paint(g);
  52. }
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement