java - The method is undefined for the type JFrame -


i encountering 2 problems eclipse! worked fine months ago before replacing broken hardware, used play lot eclipse , learnt new stuff. however, seems nothing works.

i followed tutorial: https://www.youtube.com/watch?v=1gir2r7g9ws , copy pasted , getting error:

error: not find or load main class

then started google solution 2 days, suggested check classpath wasn't sure type in cmd since have laptop borrowed school , has restrictions access areas in computer , workspace in folder requires administrator's priviledges. tried make normal helloworld class , worked without not find main class errors.

so guess problem in code, or it?

anyways, script here, window class:

package gamepackage;  import java.awt.canvas; import java.awt.dimension;  import javax.swing.jframe;  public class window extends canvas {      private static final long serialversionuid = 4882660542739611206l;      public window(int width, int height, string title, game game) {          jframe frame = new jframe(title);          frame.setpreferredside(new dimension(width, height));         frame.setmaximumside(new dimension(width, height));         frame.setminimumside(new dimension(width, height));          frame.setdefaultcloseoperation(jframe.exit_on_close);         frame.setresizable(false);         frame.setlocationrelativeto(null);         frame.add(game);         frame.setvisible(true);         game.start();      }  } 

and game class:

package gamepackage;  import java.awt.canvas; import java.awt.color; import java.awt.graphics; import java.awt.image.bufferstrategy;   public class game extends canvas implements runnable {      private static final long serialversionuid = 3429322092557125719l;      public static final int width = 640, height = width / 16 * 9;      private thread thread;     private boolean running = false;      public game () {         new window(width,height, "game project", this);     }      public synchronized void start() {         thread = new thread(this);         thread.start();         running = true;     }      public synchronized void stop() {         try{             thread.join();             running = false;         }catch(exception e)  {             e.printstacktrace();         }      }      public void run() {         long lasttime = system.nanotime();         double amountofticks = 60.0;         double ns = 1000000000 / amountofticks;         double delta = 0;         long timer = system.currenttimemillis();         int frames = 0;         while(running) {             long = system.nanotime();             delta += (now - lasttime) / ns;             lasttime = now;             while(delta >= 1) {                 tick();                 delta--;             }             if(running)                 render();             frames++;              if(system.currenttimemillis() - timer > 1000) {                 timer += 1000;                 system.out.println("fps: " + frames);                 frames = 0;             }         }         stop();     }      private void tick() {      }      private void render() {         bufferstrategy bs = this.getbufferstrategy();         if(bs == null) {             this.createbufferstrategy(3);             return;         }          graphics g = bs.getdrawgraphics();          g.setcolor(color.black);         g.fillrect(0, 0, width, height);          g.dispose();         bs.show();     }      private static void main(string[] args) {         new game();     } } 

for window class, error:

the method undefined type jframe 

so thinking can reason error? couldn't fix anyhow , normal helloworld class program works properly.

any ideas? sorry unprofessional eclipse. btw, copy pasted netbeans , yet got same main class error (and yes, changed class names , match netbean project).

thanks in advance!

you have typo in code! have write:

frame.setpreferredsize(new dimension(width, height)); frame.setmaximumsize(new dimension(width, height)); frame.setminimumsize(new dimension(width, height)); 

instead of side. wrote "d" instead of "z".


Comments

Popular posts from this blog

Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12:test (default-test) on project.Error occurred in starting fork -

windows - Debug iNetMgr.exe unhandle exception System.Management.Automation.CmdletInvocationException -

configurationsection - activeMq-5.13.3 setup configurations for wildfly 10.0.0 -