my dog learned polymorphism*
The moose likes Swing / AWT / SWT and the fly likes create screen comaptible for all resoluions? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "create screen comaptible for all resoluions?" Watch "create screen comaptible for all resoluions?" New topic
Author

create screen comaptible for all resoluions?

Parveen thakur
Greenhorn

Joined: Oct 12, 2011
Posts: 19
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]
Rob Camick
Ranch Hand

Joined: Jun 13, 2009
Posts: 2180
    
    7
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

Joined: Oct 12, 2011
Posts: 19
Thanks Rob Camick
Please suggest me ....

How i can use GridBagLayout for following code please suggest me..
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10268
    
    8

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)

[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
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

Joined: Oct 12, 2011
Posts: 19

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:



[Thumbnail for Untitled.png]

Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
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

Joined: Oct 12, 2011
Posts: 19
Thanks for asking Michael Dunn

But this is my first case
john price
Ranch Hand

Joined: Feb 24, 2011
Posts: 495

Many netbook screens are 1024X600. This post is meant to help with future compatibility.

John Price


“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” (Mosher's Law of Software Engineering)
“If debugging is the process of removing bugs, then programming must be the process of putting them in.” (Edsger Dijkstra)
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
> 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.
Ketan Borkar
Greenhorn

Joined: Oct 16, 2011
Posts: 2
try miglayout it's very easy to use and very flexible
Kristjan Toots
Ranch Hand

Joined: Jun 03, 2011
Posts: 59

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...


Please correct my english.
Parveen thakur
Greenhorn

Joined: Oct 12, 2011
Posts: 19
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

Joined: Jun 03, 2011
Posts: 59

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.
Haris Tasawar
Ranch Hand

Joined: Aug 19, 2011
Posts: 30
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

Joined: Oct 12, 2011
Posts: 19
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

Joined: Aug 19, 2011
Posts: 30
Well for that you have to set the component bounds according to the current screen resolution...
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10268
    
    8

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

Joined: Aug 19, 2011
Posts: 30
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

Joined: Jun 09, 2003
Posts: 4632
never, ever seen an app better suited
to absolute (null) positioning.

Lack of imagination/knowledge is its only friend.
Haris Tasawar
Ranch Hand

Joined: Aug 19, 2011
Posts: 30
LOL.... well if it isnt suited then why is it there???
Haris Tasawar
Ranch Hand

Joined: Aug 19, 2011
Posts: 30
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

Joined: Aug 19, 2011
Posts: 30
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..
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19684
    
  20

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


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: create screen comaptible for all resoluions?