• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

create screen comaptible for all resoluions?

 
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,
Please help me ! I have any frame in swing ,i want the frame look and feels is same for all screen resolutions,components
does not shattered/shrink ,they fits well in different resolution
dynamically e.g
Commonly used screen sizes appear to be:
1024x768
1280x800
1280x1024
1440x900
1366x768
1680x1050
1152x864
1920x1080
800x600
1600x900

Please tell tell me how i can set the frame or pannel same for all screens.
the commponents will not change there posistion and dynamically adujsst for other screen.

[Edit by Roberto Perillo: in this case, code is not needed to exemplify the question]
 
Rancher
Posts: 3324
32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Don't use setBounds().

Instead you need to use layout managers. Read the section from the Swing tutorial on Layout Managers for more information.
 
Parveen thakur
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Rob Camick
Please suggest me ....

How i can use GridBagLayout for following code please suggest me..
 
Bartender
Posts: 11497
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In future, while posting code, please UseCodeTags. I have added them for you this time. As you can see the tags make the code much more easier to read and understand.

Parveen thakur wrote:How i can use GridBagLayout for following code please suggest me..


Did you even bother to check out the link Rob provided? It has examples (free ready made code!) on how to use the layouts.

After referring to the example, if you run into any problem, you will need to post your SSCCE code so we can help you figure out whats going wrong. (Please do take out time to understand what SSCCE really means)
 
Ranch Hand
Posts: 4632
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
just tried posting this in your other thread
but it was being locked at the same time,
so i'll post it here.

for the moment forget the code.

using something like paint, draw your gui
with components. number the components
then describe what they are and whether
they occupy a % of space, or specific sizing,
and, importantly, what should happen to
each component's size if the frame is resized.

post the drawing/description here and
you might find nesting of layout managers
a far easier option than gridbaglayout
 
Parveen thakur
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


Thanks @ Saloon Keeper and Michael Dunn

But I can't set the components of frame with the help of gridboxlayout....

I can't understand how divide the screens into row and cols ..... and how i can use the different gridbagconstaints property
I send a screen shot of screen that is created with the help of setBound()
But please suggest me how i can create the same output with the help of gridboxlayout or any other solution....

Please suggest or tell me how i can solve this above example, please solve the above example make compatible for all the above resolutions...

or give me brief idea with example to solve the problem or resolutions.... :shock:

Thanks and regards:
PT :confused:

Untitled.png
[Thumbnail for Untitled.png]
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
despite all attempts to point you in the
right direction you insist on asking for
someone to 'provide a solution'.

have you just started working on a help desk,
and this is your first 'case'?
 
Parveen thakur
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Thanks for asking Michael Dunn

But this is my first case

 
Ranch Hand
Posts: 495
Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Many netbook screens are 1024X600. This post is meant to help with future compatibility.

John Price
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
> But this is my first case

it is in your own interest to learn for yourself how to do it (with prompting from here).

That way, next time you have the same/similar problem, you'll be able to provide an
almost instant response.
 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
try miglayout it's very easy to use and very flexible
 
Ranch Hand
Posts: 59
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Ketan Borkar wrote:try miglayout it's very easy to use and very flexible


Like Ketan said, you could try out MigLayout

I would suggest trying to achieve your goal on a smaller scale. There is absolutely no point of rewriting your GUI to fit your requirements without understanding how different layouts work. You would end up frustrated and disappointed.

Instead you could divide your goal to a smaller and do-able steps. You could try out different layouts on a single button. Then you could add few components here and there to try them out. Afterwards you could go on and try to preserve the look of a group of elements (like: login screen for example).

But unfortunately there is always a one prerequisite: You would have to have the will to learn...
 
Parveen thakur
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks to all my friends............
i want the idea to overcome this problem and how to solve my problem that the components of frame are adjust automatically or dynamically when i change the resolutions size the .

but i till not getting any result and idea ?
 
Kristjan Toots
Ranch Hand
Posts: 59
Eclipse IDE Firefox Browser Java
  • Likes 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Parveen thakur wrote:


but i till not getting any result and idea ?


Because you haven't tried hard enough.
At least I haven't seen any effort in this topic except for asking already built code.

Like I said, start from beginning and with very simple tasks - with a couple of elements only.
 
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
well i also got in the same problem.... and i used the defaultoolkit option to get the current resolution of the screen and fit the frame in it:

Here`s what i did:



this would return the current screen size to you and then you can set the frame bounds with using the he and wi variables.
 
Parveen thakur
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Haris Tasawar

But now the problem is that when i change the resolutions of the system the screen is fit automatically , but the all components are not present in the screen when 800X600 as compared to 1366 X 768
i means how i set the look and feel of the components same for both resolutions ....

How i can sort out this problem Haris Tasawar .

 
Haris Tasawar
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well for that you have to set the component bounds according to the current screen resolution...
 
Maneesh Godbole
Bartender
Posts: 11497
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Haris Tasawar wrote:Well for that you have to set the component bounds according to the current screen resolution...


That's exactly why one should be using a layout manager.
 
Haris Tasawar
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i agree with you maneesh that we should be using a proper layout manager, not an absolute layout.... but sometimes one has to build an app according to their own imagination and there absolute layout becomes handy....
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
never, ever seen an app better suited
to absolute (null) positioning.

Lack of imagination/knowledge is its only friend.
 
Haris Tasawar
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
LOL.... well if it isnt suited then why is it there???
 
Haris Tasawar
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Just kidding... i mean you guys are right that layouts are suitable but everyone have their choices... maybe that`s why they included it.
 
Haris Tasawar
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
But i recently created an app using null layout.... i agree it was pain and took time but got it done when i got the hang of it..
 
Sheriff
Posts: 22848
132
Eclipse IDE Spring Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Michael Dunn wrote:never, ever seen an app better suited
to absolute (null) positioning.


I have created one, once. It was a panel with draggable icons; you can't do that with a null layout. Although I did create a NullLayout class to at least calculate the preferred and minimum sizes correctly.

Haris Tasawar wrote:But i recently created an app using null layout.... i agree it was pain and took time but got it done when i got the hang of it..


Until you resize your application and everything looks messed up, or you have lots of unnecessary empty space
 
reply
    Bookmark Topic Watch Topic
  • New Topic