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

  • Home
  • SEARCH
  • 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 5838471
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T11:28:17+00:00 2026-05-22T11:28:17+00:00

In a Java SWT shell window, how do I set its inner size than

  • 0

In a Java SWT shell window, how do I set its inner size than its whole window frame size?

For instance, if I use shell.setSize(300, 250) this would make the whole window appearing as exactly 300×250. This 300×250 includes the size of the window frame.

How can I set the inner size, that is the content display region of the shell window to 300×250 instead? That’s this 300×250 excludes the width of the window frame.

I tried to minus some offset values but the thing is different Operating Systems have different window frame sizes. So having a constant offset would not be accurate.

Thanks.

  • 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-22T11:28:18+00:00Added an answer on May 22, 2026 at 11:28 am

    From your question what I understood is that you want to set the dimension of the Client Area. And in SWT lingo it is defined as a rectangle which describes the area of the receiver which is capable of displaying data (that is, not covered by the "trimmings").

    You cannot directly set the dimension of Client Area because there is no API for it. Although you can achieve this by a little hack. In the below sample code I want my client area to be 300 by 250. To achieve this I have used the shell.addShellListener() event listener. When the shell is completely active (see the public void shellActivated(ShellEvent e)) then I calculate the different margins and again set the size of my shell. The calculation and resetting of the shell size gives me the desired shell size.

    >>Code:

    import org.eclipse.swt.SWT;
    import org.eclipse.swt.events.ShellEvent;
    import org.eclipse.swt.events.ShellListener;
    import org.eclipse.swt.layout.GridData;
    import org.eclipse.swt.layout.GridLayout;
    import org.eclipse.swt.widgets.Display;
    import org.eclipse.swt.widgets.Menu;
    import org.eclipse.swt.widgets.Shell;
    
    public class MenuTest {
    
        public static void main (String [] args) 
        {
            Display display = new Display ();
            final Shell shell = new Shell (display);
    
            GridLayout layout = new GridLayout();
            layout.marginHeight = 0;
            layout.marginWidth = 0;
            layout.horizontalSpacing = 0;
            layout.verticalSpacing = 0;
            layout.numColumns = 1;
            shell.setLayout(layout);
            shell.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true,true));
            final Menu bar = new Menu (shell, SWT.BAR);
            shell.setMenuBar (bar);
    
            shell.addShellListener(new ShellListener() {
    
                public void shellIconified(ShellEvent e) {
                }
                public void shellDeiconified(ShellEvent e) {
                }
                public void shellDeactivated(ShellEvent e) {
                }
                public void shellClosed(ShellEvent e) {
                    System.out.println("Client Area: " + shell.getClientArea());
                }
                public void shellActivated(ShellEvent e) {
                    int frameX = shell.getSize().x - shell.getClientArea().width;
                    int frameY = shell.getSize().y - shell.getClientArea().height;
                    shell.setSize(300 + frameX, 250 + frameY);
                }
            });     
    
            shell.open ();
            while (!shell.isDisposed()) {
                if (!display.readAndDispatch ()) display.sleep ();
            }
            display.dispose ();
        }
    } 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In Java SWT, is there a way to draw text on a transparent shell
On my cross-platform SWT Java application, I'm using TrayItem's setImages() function to set the
I have the following code generated by Eclipse (.java file). import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Display;
In my Java SWT application I'm hosting an 3rd party ActiveX control. I'm using
Im am making an Java SWT program that is required to run on both
I do not want my Java SWT application to cache temporary internet files. Currently
I am trying to achieve better performance for my Java SWT application, and I
In my SWT Java app I often want to return information from inside a
In a Java project (SWT desktop app), I want to inform the user about
I am implementing a on screen keyboard in Java for SWT and AWT. One

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.