Not sure why i have errors

+1 Carlos Henderson · July 6, 2015
Im using netbeans and I have a  few errors in my Screen in the screen = new Screen
my restoreScreen in  screen.restoreScreen
and setFullScreen in screen.setFullScreen




package boom;
import java.awt.DisplayMode;
import java.awt.Image;
import javax.swing.*;
import java.awt.*;


import javafx.stage.Screen;
import javax.swing.ImageIcon;
/**
 * @author Carlos
 */
public class Boom {
    

   
    public static void main(String[] args) {
        
        DisplayMode displayMode = new DisplayMode(800, 600, 16, DisplayMode.REFRESH_RATE_UNKNOWN);
        Boom b = new Boom();
        b.run(displayMode);
      }      
        
       private Screen screen;
       private Image bg;
       private animation a;
       //this method loads pictures from the computer to java and adds a scene
       public void loadPics(){
           bg = new ImageIcon("c:\\test\\deathstar.jpg").getImage();
           Image nar1 =new ImageIcon("C:\\test\\1.jpg").getImage();
           Image nar2 =new ImageIcon("C:\\test\\2.jpg").getImage();
           Image nar3 =new ImageIcon("C:\\test\\3.jpg").getImage();
           a = new animation();
           a.addScene(nar1, 250);
           a.addScene(nar2, 250);
           a.addScene(nar3, 250);           
           
       }
       //main engine the RUN METHOD!
       public void run(DisplayMode dm){
           screen = new Screen();
           try{
               screen.setFullScreen(dm, new JFrame());
               loadPics();
               movieLoop();
               
           }finally{
               screen.restoreScreen();
           }
                  
       }
    //main movie loop
       public void movieLoop(){
           long startingTime =System.currentTimeMillis();
           long cumTime = startingTime;
           
           while(cumTime - startingTime <5000){
               long timePassed = System.currentTimeMillis()-cumTime;
               cumTime += timePassed;
               a.update(timePassed);
               
                              
           }
       } 
}
   
   

Post a Reply

Replies

Oldest  Newest  Rating
0 Nishant K · July 30, 2015
I have allready installed Hax Intel package but still showing this error. why?
Cannot launch AVD in emulator.
Output:
emulator: ERROR: x86 emulation currently requires hardware acceleration!
Please ensure Intel HAXM is properly installed and usable.
CPU acceleration status: HAX kernel module is not installed!
0 Carlos Henderson · July 30, 2015
that actually helped and i figured out the problem in the screen class too, thanks guys!
0 Nicholas Eason · July 19, 2015
We need to see your Screen class, since that's where the errors are happening.
0 Kenneth Malicay · July 7, 2015
First I would suggest using the code tags when posting codes for readability. (It's above the comment box)
e.g.
for(i = 0; i < 5; i++) {
if(ppg > bestPPG) {
bestPPG = ppg;
bestPlayer = player;
}
}

And also as far as I know, it's always a good practice to declare your global variable at the very top of your class.
It also might be why you're getting error.
e.g.
public class Boom {
// global variables declaration here
private Screen screen;
private Image bg;
private animation a;

// methods and stuff here
public static void main(String[] args) {
DisplayMode displayMode = new DisplayMode(800, 600, 16, DisplayMode.REFRESH_RATE_UNKNOWN);
Boom b = new Boom();
b.run(displayMode);
}
}

Also I would like to ask what error are you getting.
  • 1

Java / Android Development

107,085 followers
About

Very popular language used to create desktop applications, website applets, and Android apps.

Links
Moderators
Bucky Roberts Administrator