I want to have JFrame with size that fits my screen perfectly. I used getScreenSize();
to get resolution of my computer and set it to JFrame
's size. However i found that Jframe's size is actually bigger than my computer's resolution because of the titlebar. (which mean u will find bottom of the jframe is behind window taskbar)
The following code demostrate my problem :
import java.awt.Dimension;
import java.awt.Toolkit;
import javax.swing.JFrame;
public class Titlebar extends JFrame {
private final Dimension _screenSize = Toolkit.getDefaultToolkit().getScreenSize();
public void run(){
this.setTitle("TitleBar");
this.setSize(_screenSize);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setVisible(true);
}
public static void main(String[] args) {
Titlebar test = new Titlebar();
test.run();
}
}
is that possible to set the jframe size minus titlebar's size ?