Advertisement
Guest User

Untitled

a guest
Jun 29th, 2017
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.03 KB | None | 0 0
  1. import javax.swing.JFrame;
  2. import java.awt.*;
  3.  
  4.  
  5. public class Simple extends JFrame
  6. {
  7.  
  8. public int why=50;
  9. public int ex=50;
  10.  
  11. public Simple()
  12. {
  13. //Set JFrame title
  14. super("HOOWAH");
  15.  
  16. //Set default close operation for JFrame
  17. setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  18.  
  19. //Set JFrame size
  20. setSize(1024,800);
  21.  
  22. //Make JFrame visible
  23. setVisible(true);
  24. }
  25.  
  26. public void paint(Graphics g)
  27. {
  28. super.paint(g);
  29.  
  30. g.drawString("TEXTXTXTTXT", 512, 100);
  31. setBackground(Color.BLACK);
  32. g.setColor(Color.RED);
  33. System.out.println("lol");
  34.  
  35. //Draw a filled rectangle(x,y,width,height)
  36. g.fillRect(ex,why,100,10);
  37. }
  38.  
  39.  
  40.  
  41. public void run(){
  42. boolean Stop = false;
  43.  
  44. while (Stop==false){
  45.  
  46. ex+= 1;
  47. why+= 1;
  48. repaint();
  49. try{
  50. Thread.sleep(10);
  51. }catch(Exception Ex){}
  52. if(ex>500){Stop=true;}
  53.  
  54.  
  55. }
  56. }
  57.  
  58.  
  59. public static void main(String[]args)
  60. {
  61. Simple RunSimple=new Simple();
  62.  
  63.  
  64. }
  65. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement