Reputation:
I am try to write a JFrame App which I want fullscreen (and by this I do not mean maximized), however the Application UI is very small (about 500x600) is there a possible way I could set the resolution of a fullscreen JFrame to 1024x768 that will work on Linux and Windows? I was simply using this code:
setUndecorated(true);
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
setBounds(0,0,screenSize.width, screenSize.height);
However I could not find a way to modify the resolution and it still displays the task panel.
I am developing in eclipse on Linux Mint 14 KDE. Thanks in advance!
EDIT : I got a little further using this code:
setUndecorated( true );
setResizable( false );
setAlwaysOnTop( true );
setVisible( true );
GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment();
DisplayMode dm = new DisplayMode(1024, 768, 16, DisplayMode.REFRESH_RATE_UNKNOWN);
vc = env.getDefaultScreenDevice();
vc.setFullScreenWindow(this);
if (dm != null && vc.isDisplayChangeSupported()){
try{
vc.setDisplayMode(dm);
}catch (Exception e){
System.exit(0);
}
}
that code was inside the contructor of my class that extends JFrame. However it does not change the resolution, it just runs at default 1080p.
Upvotes: 0
Views: 609
Reputation: 347194
Take a look at Full Screen Exclusive Mode API for full details, it take special note of Display Mode
Upvotes: 1
Reputation: 13066
is there a possible way I could set the resolution of a fullscreen JFrame to 1024x768 that will work on Linux and Windows.
If you want your JFrame
to be shown on entire screen then you can use this one:
setUndecorated(true);
setExtendedState(JFrame.MAXIMIZED_BOTH);
toFront();
Upvotes: 1