Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Very Silly UI resize problem

 
Suchak Jani
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Team,
I am trying to get the maximum screen size and the resize my UI accordingly. It just does not seem to work.
I have tried both :
resize using Dimension on the frame.
resize using int width and int height on the frame.

I have the following code

I know this must be very silly, but i cannot figure it out.
Regards
Suchak Jani
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I simply hard coded the size and made it not resizable
Here's the code I used

Mark
 
Suchak Jani
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Mark
I guess i will do the same.
Thanks and Regards
Suchak Jani
 
Rajesh Matti
Ranch Hand
Posts: 121
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Suchak - Problem is with your code. To get the max dimension use ToolKit.getDefaultToolKit().getScreenSize() and set your frame's size to that.
-Rajesh
 
tom mcmorrow
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi all
I was wondering if setting it as mark suggests limits the application to monitors with resolutions of greater than width 900. I have used rajesh method however i find on a large screen it looks somewhat out of propotion for my particular UI.
tom
 
Suchak Jani
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rajesh,
Suchak - Problem is with your code. To get the max dimension use ToolKit.getDefaultToolKit().getScreenSize() and set your frame's size to that.
Yes ! it works.
Dimension d = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
f.setSize((int)(d.getWidth()),(int)(d.getHeight()/2));
I do not get why though ?
I mean the code that does not work below:-
Dimension d = f.getMaximumSize();
f.setSize((int)(d.getWidth()),(int)(d.getHeight()/2));
looks just like the above code that works.
Both return Dimension Objects and then based on that Object try to set the frame size.
Can some more light be thrown on why ?
Note: i have tested both and i am sure that one works and the other does not.
Regards
Suchak Jani
[ March 13, 2002: Message edited by: Suchak Jani ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic