By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,654 Members | 1,519 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,654 IT Pros & Developers. It's quick & easy.

Automatically set screen size according to monitor size using swing

100+
P: 126
I have created a desktop application using java swing on a system with resolution- 1920 x 1080. When i run this application on a lower resolution screen the screen size seems to be to large to be visible on the lower screen resolution sizes. How do i overcome this problem using programming?

I have tried below code, which is not satisfying
Expand|Select|Wrap|Line Numbers
  1. Toolkit t = Toolkit.getDefaultToolkit();
  2.         Dimension d = t.getScreenSize();
  3.         int h = d.height;
  4.         int w = d.width;
  5.         this.setSize( 1200 , 950 );

Any other options please..
May 30 '13 #1
Share this Question
Share on Google+
3 Replies


Nepomuk
Expert 2.5K+
P: 3,112
You set the size to 1200x950 no matter what? Shouldn't that be
Expand|Select|Wrap|Line Numbers
  1. this.setSize(w, h);
then?

Also, what exactly is what you want it to do? Go fullscreen? If so, maybe
Expand|Select|Wrap|Line Numbers
  1. this.setExtendedState(JFrame.MAXIMIZED_BOTH);
will be the easiest solution.
May 30 '13 #2

100+
P: 126
i shall try this and get back to you.
May 31 '13 #3

P: 1
Try this...
Select all components of JFrame, right click, select 'Auto Resizing', check for both Horizontal and Vertical, close .
Jun 18 '16 #4

Post your reply

Sign in to post your reply or Sign up for a free account.