Actual size of JFrame

I have made a JFrame clearly through Java and set the size so that it is as large as possible on the screen. For instance I will use Toolkit.getDefaultToolkit().getScreenSize() to set the size of the JFrame, but because of the menu bar / dock etc. (in windows and mac) it gets resized to fit the screen. How would I be able to get this new dimension, which the JFrame defaults to?


I don't know if I am understanding your question correctly. But if you want to get the size of the screen minus the menu bar / task bar, this answer could help.

If you simply want to get the new dimensions of your JFrame then use:


To maximize the JFrame, you add maximized both to the extended state.

frame.setExtendedState(frame.getExtendedState() | JFrame.MAXIMIZED_BOTH);

On Windows XP, this maximization takes into account the Windows status bar. However, the horizontal calculation is a few pixels off, and you won't see all of the side borders.

I've not tried this on Windows 7 or Unix.

You should also set a JFrame size, in case the user clicks on the maximize / restore size button (the middle button on a Windows JPanel).

Need Your Help


html jstl

im trying to make a hyperklink in a textarea that possible?

Why in Python, += and -= are considered as delimiters?

python operators delimiter

I am reading a tutorial about python, it's lexical structure to be more precise.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.