Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Feb 2012
    Posts
    9
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Full Screen Not Working

    I am making a full screen gui and then putting a picture on it. I can get the picture to display in windowed mode however whenever i display it in full screen it does not work.
    Here is the code I use for making it full screen:
    [CODE]
    GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
    GraphicsDevice gd = ge.getDefaultScreenDevice();
    GraphicsConfiguration gc = gd.getDefaultConfiguration();
    gd.setFullScreenWindow( frame );
    if( gd.isDisplayChangeSupported() ) {
    gd.setDisplayMode(
    new DisplayMode( 640, 480, 32, DisplayMode.REFRESH_RATE_UNKNOWN )
    );
    } [CODE]



    Here is my full code:

    [CODE]
    import java.awt.*;
    import java.awt.image.BufferedImage;
    import java.awt.image.ImageProducer;
    import java.io.*;
    import javax.imageio.ImageIO;
    import javax.swing.*;

    public class **** extends Canvas{
    Image image;

    public ****() {
    MediaTracker media = new MediaTracker(this);
    image = Toolkit.getDefaultToolkit().getImage("pokemon.png");
    media.addImage(image, 0);
    try {
    media.waitForID(0);
    }
    catch (Exception e) {}
    }

    public ****(ImageProducer imageProducer){
    image = createImage(imageProducer);
    }

    public void paint(Graphics g) {
    g.drawImage(image, 0,0, this);
    Graphics2D g2d = null;

    }

    public static void main(String args[]) {
    Frame frame = new Frame();
    frame.setLayout(new BorderLayout());
    frame.add("Center", new ****());
    frame.resize(400,400);
    GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
    GraphicsDevice gd = ge.getDefaultScreenDevice();
    GraphicsConfiguration gc = gd.getDefaultConfiguration();
    gd.setFullScreenWindow( frame );
    if( gd.isDisplayChangeSupported() ) {
    gd.setDisplayMode(
    new DisplayMode( 640, 480, 32, DisplayMode.REFRESH_RATE_UNKNOWN )
    );
    }
    frame.show();
    }
    }
    [CODE]

  • #2
    New to the CF scene
    Join Date
    Feb 2012
    Posts
    9
    Thanks
    2
    Thanked 0 Times in 0 Posts
    Oh sry my class was named **** spelled 's' 'h' 'i' 't' and that is why the class names are **** and the constructor is ****() and it goes new ****().


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •