Source code to determine display mode for current screen can change or not using java


***********************************************************
COMPLETE SOURCE CODE FOR : DetermineDisplayModeCanChangeOrNot.java
***********************************************************


import java.awt.GraphicsEnvironment;
import java.awt.GraphicsDevice;

public class DetermineDisplayModeCanChangeOrNot
{
public static void main(String[]args)
{
GraphicsEnvironment ge=GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsDevice gd=ge.getDefaultScreenDevice();

//METHOD isDisplayChangeSupported() returns true if this GraphicsDevice supports low-level display changes.
boolean change=gd.isDisplayChangeSupported();

if(change==true)
{
System.out.println("DISPLAY MODE CAN CHANGE");
}

else
{
System.out.println("DISPLAY MODE CANNOT CHANGE");
}
}
}


***********************************************************
JUST COMPILE AND EXECUTE IT
***********************************************************

Current refresh rate


*****************************************************************
COMPLETE SOURCE CODE FOR : RefreshRateForCurrentScreen.java
*****************************************************************


import java.awt.GraphicsEnvironment;
import java.awt.GraphicsDevice;
import java.awt.DisplayMode;

public class RefreshRateForCurrentScreen
{
public static void main(String[]args)
{
GraphicsEnvironment ge=GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsDevice gd=ge.getDefaultScreenDevice();
DisplayMode dm=gd.getDisplayMode();

//Print refresh rate for current screen
System.out.println("REFRESH RATE FOR CURRENT SCREEN : "+dm.getRefreshRate());
}
}


*****************************************************************
JUST COMPILE AND EXECUTE IT
*****************************************************************

Current bit depth


*******************************************************************
COMPLETE SOURCE CODE FOR : CurrentBitDepth.java
*******************************************************************


import java.awt.GraphicsEnvironment;
import java.awt.GraphicsDevice;

import java.awt.DisplayMode;

public class CurrentBitDepth
{
public static void main(String[]args)
{
//HOW TO GET CURRENT SCREEN BIT DEPTH

GraphicsEnvironment ge=GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsDevice gd=ge.getDefaultScreenDevice();
DisplayMode dm=gd.getDisplayMode();

//Print current bit depth
System.out.println("CURRENT SCREEN BIT DEPTH IS: "+dm.getBitDepth());
}
}


*******************************************************************
JUST COMPILE AND EXECUTE IT
*******************************************************************

Second full screen


***********************************************************************
COMPLETE SOURCE CODE FOR : FullScreenInJava2.java
***********************************************************************


import java.awt.Frame;
import java.awt.Button;

import java.awt.Dimension;
import java.awt.Toolkit;

import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;

import java.awt.FlowLayout;

public class FullScreenInJava2
{
public static void main(String[]args)
{
Frame a=new Frame();
Button b=new Button("CLICK HERE TO DISABLE FULL SCREEN");

ActionListener al=new ActionListener()
{
public void actionPerformed(ActionEvent evt)
{
System.exit(0);
}
};

b.addActionListener(al);

a.setLayout(new FlowLayout());
a.add(b);

a.setSize((Toolkit.getDefaultToolkit().getScreenSize()).width,(Toolkit.getDefaultToolkit().getScreenSize()).height);
a.setUndecorated(true);
a.setAlwaysOnTop(true);
a.setVisible(true);
}
}


***********************************************************************
JUST COMPILE AND EXECUTE IT
***********************************************************************

First full screen


********************************************************************
COMPLETE SOURCE CODE FOR : FullScreenInJava.java
********************************************************************


import java.awt.GraphicsEnvironment;
import java.awt.GraphicsDevice;

import java.awt.Frame;
import java.awt.Window;
import java.awt.Button;

import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.awt.event.WindowListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

import java.awt.FlowLayout;

import java.awt.Color;

public class FullScreenInJava
{
public static void main(String[]args)
{
GraphicsEnvironment ge=GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsDevice gd=ge.getDefaultScreenDevice();

ActionListener al=new ActionListener()
{
public void actionPerformed(ActionEvent evt)
{
GraphicsEnvironment ge2=GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsDevice gd2=ge2.getDefaultScreenDevice();
gd2.setFullScreenWindow(null);
}
};

Frame a=new Frame();

Button b=new Button("CLICK HERE TO DISABLE FULL SCREEN");
b.addActionListener(al);

WindowListener wl=new WindowAdapter()
{
public void windowClosing(WindowEvent evt)
{
System.exit(0);
}
};

a.addWindowListener(wl);
a.setSize(300,300);

Window c=new Window(a);
c.setAlwaysOnTop(true);
c.setLayout(new FlowLayout());
c.setBackground(Color.DARK_GRAY);
c.add(b);
gd.setFullScreenWindow(c);
c.validate();
}
}


********************************************************************
JUST COMPILE AND EXECUTE IT
********************************************************************

Determine platform support for full screen


*******************************************************************
COMPLETE SOURCE CODE FOR : DetermineFullScreenSupport.java
*******************************************************************


import java.awt.Frame;
import java.awt.Window;

import java.awt.GraphicsEnvironment;
import java.awt.GraphicsDevice;

public class DetermineFullScreenSupport
{
public static void main(String[]args)
{
GraphicsEnvironment ge=GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsDevice gd=ge.getDefaultScreenDevice();

if(gd.isFullScreenSupported())
{
System.out.println("FULL SCREEN SUPPORTED");
}
else
{
System.out.println("FULL SCREEN NOT SUPPORTED");
}
}
}


*******************************************************************
JUST COMPILE AND EXECUTE IT
*******************************************************************

RELAXING NATURE VIDEO