Java - Full screen in 16Bit

0

How can I put a JFrame in full screen and change the screen resolution using:

device.setDisplayMode(new DisplayMode(Width,Height,16,DisplayMode.REFRESH_RATE_UNKNOWN));

Should I use a new library?

Thank you

    
asked by anonymous 15.10.2017 / 05:26

1 answer

2

Your video card or video driver does not support the change, especially if your driver is generic, for example using a newer operating system than your video, for example in my case the video only provides 32bit, this may be due to onboard or because I installed Window 8.1 for an older card, of which its support only goes to Windows 7.

To find out which modes your system does the following path (if you use Windows):

  • Right-click the mouse / mouse on the desktop
  • Select Screen resolution
  • Click Advanced Settings
  • In the window that you opened look for the button List modes

This will appear:

Notethatall"modes" only support 32 bits , I think that using 16 bits these days is unnecessary

  

As I read, modern systems do not need more than 16 bits, or anything less than 32 bits, there are techniques (which probably only programs with administrator accesses can use), one of them is to put the program to start with compatibility mode, however the process is all manual and can not do this for Java (unless it is a gambiarra using the Windows APIs), example:

     

HowtodetectsupportforchangingdisplaywithJava

Tomakesureyousupportit,youcantestthefunction:

GraphicsDevice.isDisplayChangeSupported

Andin%usetry/catch:

try{device.setDisplayMode(displayMode);}catch(Throwablee){//Pegaoerroe.getMessage}

HowtoputJFrameinfullescreen

NowtoleavesetDisplayModeinfullscreen,regardlessofthesupportofyourvideocardand/ordriveryoucanusethisway:

frame.setExtendedState(JFrame.MAXIMIZED_BOTH);//Maxmizaframe.setUndecorated(true);//Removeadecoraçãodajanela

ThiswillleaveyourJFrameonfullscreen,butdoesnotmeanthatitwillchangethescreenresolution.

  

Note:IaddedJFrameonlytodisplaymessagestoseewhathappened

importjava.awt.DisplayMode;importjava.awt.GraphicsDevice;importjava.awt.GraphicsEnvironment;importjavax.swing.JFrame;importjavax.swing.JOptionPane;publicclassMain{publicstaticvoidmain(String[]argv)throwsException{finalGraphicsEnvironmentge=GraphicsEnvironment.getLocalGraphicsEnvironment();finalGraphicsDevicedevice=ge.getDefaultScreenDevice();finalintwidth=640;finalintheight=480;if(device.isDisplayChangeSupported()){finalDisplayModedisplayMode=newDisplayMode(width,height,16,DisplayMode.REFRESH_RATE_UNKNOWN);try{device.setDisplayMode(displayMode);JOptionPane.showMessageDialog(null,"Mudou a resolução");
            } catch (Throwable e) {
                device.setFullScreenWindow(null);
                JOptionPane.showMessageDialog(null, e.getMessage());
            }
        } else {
            JOptionPane.showMessageDialog(null, "Sem suporte para mudar a resolução");
        }

        final JFrame frame = new JFrame("Minha primeira janela");
        frame.setExtendedState(JFrame.MAXIMIZED_BOTH); //Maxmiza
        frame.setUndecorated(true); //Remove a decoração da janela
        frame.setVisible(true);
    }
}
    
15.10.2017 / 17:18