Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: I need help with my FullScreen Code

  1. #1
    Member
    Join Date
    Oct 2011
    Posts
    37
    My Mood
    Where
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default I need help with my FullScreen Code

    I am trying to get a simple fullscreen window for a game I am making. I have the code in my Screen class (With no apparent errors). I need to know how to run the fullscreen code from my FullScreenWindow class.

    Here is the code for the Screen class:
    import java.awt.BorderLayout;
    import java.awt.Color;
    import java.awt.Font;
    import java.awt.GraphicsDevice;
    import java.awt.GraphicsEnvironment;
     
    import javax.swing.JFrame;
    import javax.swing.JLabel;
     
    @SuppressWarnings("serial")
    public class Screen extends JFrame{
     
      public Screen( String title )
      {
          super(title);
     
          this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
     
          FullScreenWindow frame = new FullScreenWindow();
          frame.setVisible(true);
     
          GraphicsDevice gd = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();
     
          setUndecorated(true);
          if (gd.isFullScreenSupported()) {
              setUndecorated(true);
              gd.setFullScreenWindow(this);
          } else {
              System.err.println("Full screen not supported");
              setSize(100, 100); // just something to let you see the window
              setVisible(true);
          }
          getContentPane().add(new JLabel("Test Fullscreen"), BorderLayout.NORTH);
          setBackground(Color.BLUE);
          setForeground(Color.WHITE);
          setFont(new Font("Arial", Font.PLAIN, 24));
          drawString("This is cool", 200, 200);
          if(isVisible() == true){
        	  try{
        		  try {
    				Thread.sleep(5000);
    			} catch (Exception ex) {
    				ex.printStackTrace();
    			}
        	  }finally{
        		  Screen.this.setVisible(false);
                  System.exit(0);
        	  }
          }
      }
     
     
     
    private void drawString(String string, int i, int j) {
    	// TODO Auto-generated method stub
     
    }
    }

    Here is the code in my FullScreenWindow class (my main class)

    import java.awt.*;
    import javax.swing.*;
    @SuppressWarnings("serial")
    public class FullScreenWindow extends JFrame {
    }


  2. #2
    Member
    Join Date
    Oct 2011
    Posts
    50
    My Mood
    Fine
    Thanks
    2
    Thanked 1 Time in 1 Post

    Default Re: I need help with my FullScreen Code

    Try this for reference: Enabling Full-Screen Mode | Example Depot

    application context
    Last edited by daniel.j2ee; December 13th, 2011 at 03:58 PM.

Similar Threads

  1. describe this program code by code ....
    By izzahmed in forum What's Wrong With My Code?
    Replies: 2
    Last Post: October 29th, 2011, 11:03 PM
  2. Applet and Fullscreen !!
    By rt4ever in forum Java Applets
    Replies: 21
    Last Post: September 5th, 2011, 07:43 PM
  3. FullScreen isn't working in Win 7
    By Ahmed.Ibrahem in forum AWT / Java Swing
    Replies: 0
    Last Post: February 6th, 2011, 10:48 AM