fork download
  1. package javaapplication9;
  2.  
  3. import java.awt.Color;
  4. import java.awt.Font;
  5. import java.awt.Graphics;
  6. import java.awt.Image;
  7. import java.awt.event.KeyAdapter;
  8. import java.awt.event.KeyEvent;
  9. import javax.swing.ImageIcon;
  10. import javax.swing.JFrame;
  11.  
  12. public class JavaApplication9 extends JFrame {
  13.  
  14. int x, y;
  15. private Image dbImage;
  16. private Graphics dbg;
  17. Image face;
  18.  
  19. Font font = new Font("Arial", Font.BOLD, 30);
  20.  
  21. public class AL extends KeyAdapter{
  22. public void keyPressed(KeyEvent e){
  23. int keyCode = e.getKeyCode();
  24. if(keyCode == e.VK_LEFT){
  25. x += -10;
  26. }
  27. if(keyCode == e.VK_RIGHT){
  28. x += +10;
  29. }
  30. if(keyCode == e.VK_UP){
  31. y += -10;
  32. }
  33. if(keyCode == e.VK_DOWN){
  34. y += +10;
  35. }
  36. }
  37. }
  38.  
  39.  
  40. public JavaApplication9(){
  41. //Loading Images
  42. ImageIcon i = new ImageIcon("C:/Documents and Settings/studio/My Documents/NetBeansProjects/JavaApplication9/src/javaapplication9/reddevilhead.gif");
  43. face = i.getImage();
  44.  
  45. //Game Properties
  46. addKeyListener(new AL());
  47. setTitle("Battle Fortess 8 Alpha _.1");
  48. setSize(250, 250);
  49. setResizable(true);
  50. setVisible(true);
  51. setBackground(Color.green);
  52. setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  53.  
  54. x = 150;
  55. y = 150;
  56. }
  57. public void paint (Graphics g){
  58. dbImage = createImage(getWidth(), getHeight());
  59. dbg = dbImage.getGraphics();
  60. paintComponent(dbg);
  61. g.drawImage(dbImage, 0, 0, this);
  62.  
  63.  
  64. }
  65. public void paintComponent(Graphics g){
  66. g.drawImage(face, x, y, this);
  67. }
  68. public static void main(String[] args){
  69. new JavaApplication9();
  70. }
  71. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
Main.java:12: error: class JavaApplication9 is public, should be declared in a file named JavaApplication9.java
public class JavaApplication9 extends JFrame {
       ^
1 error
stdout
Standard output is empty