I have this problem, that whenever I set the frame size using the setSize () method the size inside the frame is actually smaller, because the frame size is included in this dimension. My question is how would I make it so that the inside of the frame is the size that I specify?
sirlink99
56
Practically a Master Poster
Recommended Answers
Jump to PostJComponents must returns ScreenSize, not JFrame#setSize();
1/ don't use setSize()
2/ don't usee setBounds()
3/ JFrame#setSize() is including "blueColoredToolbar" + EtechedBorder that came from Native OS
4/ set preferredSize ...
5/ I talking about that in your thread ...
6/ setSize() and setBounds() multiplayed …
Jump to PostA JFrame consists of a Content Pane surrounded by borders etc and, as you have observed, its size includes the (system-dependent) borders.
To achieve your desired result, set the (preferred) size of the JFrame's Content Pane (access it via myFrame.getContentPane()) rather than the JFrame itself.
Jump to PostYes, the serial ID and runnable would be used in a real app- I left them out because they weren't essential to the demo point.
But, by removing the getContentPane on your line 21 you have broken it. It's now 150x150 including the frame. The whole point of this is …
All 12 Replies
mKorbel
274
Veteran Poster
JamesCherrill
4,733
Most Valuable Poster
Team Colleague
Featured Poster
mKorbel
274
Veteran Poster
JamesCherrill
4,733
Most Valuable Poster
Team Colleague
Featured Poster
hfx642
sirlink99
56
Practically a Master Poster
JamesCherrill
4,733
Most Valuable Poster
Team Colleague
Featured Poster
JamesCherrill
4,733
Most Valuable Poster
Team Colleague
Featured Poster
mKorbel
274
Veteran Poster
JamesCherrill
4,733
Most Valuable Poster
Team Colleague
Featured Poster
mKorbel
274
Veteran Poster
JamesCherrill
4,733
Most Valuable Poster
Team Colleague
Featured Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.