Mohamed EL Tair
Mohamed EL Tair

Reputation: 357

java JFrame height excluding title bar?

when you specify height for JFrame the title bar consumes a part of this height, is there a method or something to know the amount of this consumed part ?

Upvotes: 1

Views: 3152

Answers (2)

MadProgrammer
MadProgrammer

Reputation: 347332

You shouldn't care about the size of the frame itself, instead, allow the content to determine its own size, using the layout management API and then call JFrame#pack which will wrap the frame around it, taking into account the frames border decorations automatically

Upvotes: 1

A.Grandt
A.Grandt

Reputation: 2262

JFrame has a method called getInsets()

From the Javadoc:

getInsets
public Insets getInsets()

Determines the insets of this container, which indicate the size of the container's border. 
A Frame object, for example, has a top inset that corresponds to the height of the frame's title bar.

Upvotes: 4

Related Questions