Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 679549
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T01:16:19+00:00 2026-05-14T01:16:19+00:00

I am just messing around trying to make a game right now, but I

  • 0

I am just messing around trying to make a game right now, but I have had this problem before too. When I specify a specific window size (1024 x 768 for instance) the window produced is just a little larger than what I specified. Very annoying. Is there a reason for this? How do I correct it so the window created is actually the size I want instead of being just a little bit bigger? Up till now I have always just gone back and manually adjusted the size a few pixels at a time until I got the result I wanted, but that is getting old. If there was even a formula I could use that would tell me how many pixels I needed to add/subtract from my my variable that would be excellent!

P.S. I don’t know if my OS could be a factor in this, but I am using W7X64.

private int windowWidth = 1024;
private int windowHeight = 768;

public SomeWindow() {
    this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    this.setSize(windowWidth, windowHeight);
    this.setResizable(false);
    this.setLocation(0,0);
    this.setVisible(true);
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T01:16:19+00:00Added an answer on May 14, 2026 at 1:16 am

    I want the total frame that Windows
    creates to be the exact size I specify

    I don’t understand your problem. Post your SSCCE that shows the problem.

    If I run code like:

    frame.setResizable(false);
    frame.setSize(1024, 768);
    frame.setVisible(true);
    System.out.println(frame.getSize());
    

    It displays java.awt.Dimension[width=1024,height=768], is that not what you expect?

    If there was even a formula I could
    use that would tell me how many pixels
    I needed to add/subtract from my my
    variable that would be excellent!

    Maybe you are referring to the space occupied by the title bar and borders?

    import java.awt.*;
    import javax.swing.*;
    
    public class FrameInfo
    {
        public static void main(String[] args)
        {
            GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment();
            Rectangle bounds = env.getMaximumWindowBounds();
            System.out.println("Screen Bounds: " + bounds );
    
            GraphicsDevice screen = env.getDefaultScreenDevice();
            GraphicsConfiguration config = screen.getDefaultConfiguration();
            System.out.println("Screen Size  : " + config.getBounds());
    
            JFrame frame = new JFrame("Frame Info");
            System.out.println("Frame Insets : " + frame.getInsets() );
    
            frame.setSize(200, 200);
            System.out.println("Frame Insets : " + frame.getInsets() );
            frame.setVisible( true );
    
            System.out.println("Frame Size   : " + frame.getSize() );
            System.out.println("Frame Insets : " + frame.getInsets() );
            System.out.println("Content Size : " + frame.getContentPane().getSize() );
         }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm just messing around with some C++ at the moment trying to make a
I just started messing around with C#/.NET/mono and stuff, and I'm trying to make
I have just about no experience messing around with formulas in Excel, but I'm
Im just messing around with Ruby on Rails and HTML. This question isn't about
I'm just messing around trying to learn a little bit about parallel computing. If
I am messing around with a basic CAAnimation example where Im just trying to
I was just messing around with XNA and trying to get a simple player
I've just started messing around with F# and am trying to do some basic
I've just been messing around with file_get_contents() at school and have noticed, it allows
I was just messing around to answer someone's question here on Stack Overflow, when

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.