• 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:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

replacing objects in diff sized monitors

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi friends, I developed a java program for 15 inch monitor... now that s/w has to be run in 21 inch monitor.. I want to generalize the positions of all swing objects... Please give me a suggestion so that it can run on the system with any sized monitor..
 
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
Hi Sunil.
Welcome to the ranch. We are happy to have you here

By "swing objects" I take it you mean all the components which have been added to the frame/window.

Usually one uses layout managers to define the relative positions of components in its container (as opposed to using a null layout manager and specifying absolute positions using the setBounds() method).
Have you used layout managers in your application?

If the application looks good on a 15" monitor, I would suggest not to tamper with it for other sizes. Usually one defines the minimum screen requirement and designs the UI accordingly. I am sure you must have seen something like "Best viewed on IE7 with 1024x768" kind of stuff lots of times
 
Sunil chintu
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Maneesh, thanks for your suggestion...
I completed the coding part using null layout manager..
So is there any other way for me now?
 
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
Well you can always generate and maintain a mapping.
e.g for
@ AxB resolution bounds for component1 should be..
@ AxB resolution bounds for component2 should be..
.
.
.
@ CxD resolution bounds for component1 should be..
@ CxD resolution bounds for component2 should be..
.
.
..and so forth.
Then at runtime, you load the required mapping and position your components accordingly. But as you can see this is quite a time consuming and tedious task.

An elegant and highly recommended solution would be to use LayoutManagers.
Like I said previously, decide on the minimum configuration like 1024x768 and use the layout managers.
Of course this means changing most of your GUI building code, but it will be a one time effort.

Just curious. Why did you use the null layout?
[ November 05, 2008: Message edited by: Maneesh Godbole ]
 
Sunil chintu
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
ok once again thanks for your suggestion to use layout managers, but can you
tell me which layout manager is good for designing?
Actually this is the first java GUI I developed... So I was in hurry to do
this.. So to make it fast, I used NULL layout manager.
Hey I have one more doubt... I want to disable close, minimize and maximize option of window... what is the API for that?
And I want my software to run in background... that is, it should
come in right side of taskbar and if I click that, then it should open... what to do for that..
Sorry :roll: I am asking so many doubts to you...
 
Sunil chintu
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
ok once again thanks for your suggestion to use layout managers, but can you
tell me which layout manager is good for designing?
Actually this is the first java GUI I developed... So I was in hurry to do
this.. So to make it fast, I used NULL layout manager.
Hey I have one more doubt... I want to disable close, minimize and maximize option of window... what is the API for that?
And I want my software to run in background... that is, it should
come in right side of taskbar and if I click that, then it should open... what to do for that..
Sorry :roll: I am asking so many doubts to you...
 
Author
Posts: 986
3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Sunil chintu:
Please give me a suggestion so that it can run on the system with any sized monitor..



Actually this is the first java GUI I developed... So I was in hurry to do this.. So to make it fast, I used NULL layout manager.



How does this happen? I mean it's somewhat of non-trivial to figure out
how to use the null layout manager, and it's really no easier than using
an actual layout manager (for typical beginning projects, anyway). So
how come we periodically encounter beginners that have used the null
layout manager asking questions here? Is there a book or something that
suggests it?

Anyway, Sunil, one of the reasons layout managers exist is to handle
running on any sized monitor gracefully. Of course it is possible to
do some arithmetic with the null layout manager and have things work
smoothly, but it would be much easier to simply use actual layout
managers and have them deal with it. It's not difficult once you put
in some basic work to discover how layout managers are supposed to work.
 
Marshal
Posts: 80295
434
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You will find lots about creating GUIs here. Lots and lots! It includes layouts, but some people say you ought to Google for MigLayout as being the best manager.
And if you go through the API for GUIs, probably the Window class, you find methods like setResizable. That's probably what you want.
 
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

Originally posted by Brian Cole:

How does this happen? I mean it's somewhat of non-trivial to figure out
how to use the null layout manager, and it's really no easier than using
an actual layout manager (for typical beginning projects, anyway). So
how come we periodically encounter beginners that have used the null
layout manager asking questions here? Is there a book or something that
suggests it?



Long time back, I remember trying out some DND GUI Builder (Visual Cafe if I remember correctly) In that version, I could specify the absolute location of a component which obviously got translated to the bounds internally.
So this might be such kind of code.
 
Sunil chintu
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you Maneesh Godbole, Brian Cole, Campbell Ritchie for your valuable suggestion... I will recode the GUI with layout managers.. If I get any doubt, I will get back to you...

But I asked some more doubts... Please send solutions for that..

I want to disable close, minimize and maximize option of window... what is the API for that?
And I want my software to run in background... that is, it should
come in right side of taskbar and if I click that, then it should open... what to do for that..
 
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

... that is, it should
come in right side of taskbar and if I click that, then it should open... what to do for that..



Do you mean the System Tray?
 
Sunil chintu
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
yeah its system tray.....
 
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

Originally posted by Sunil chintu:
yeah its system tray.....



So did you check out the link I had provided? Was it helpful?
 
Sunil chintu
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yeah its really useful...
but i am not getting how to make my application to get into system tray..
please don't feel bad i am really getting all from you only..... :roll:
 
Sheriff
Posts: 22822
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
Have you tried the code in the link Maneesh has given you? Then you should know how to create a tray icon.

As for minimizing to the tray, all you need to do is add a WindowListener to your (J)Frame that responds to the iconified event. If that one occurs, add the tray icon (if not added already) and call setVisible(false) on the (J)Frame.

Don't forget to change the frame's (extended) state back when you show it again or it will remain iconified (minimized). And if you want to know which method to use for that, read my previous sentence
 
Sunil chintu
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
yeah i will do that... thanks to all.. especially maneesh
 
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

Originally posted by Sunil chintu:
yeah i will do that... thanks to all.. especially maneesh



You are welcome. Hope you get your solution working the way you want it.
Best of luck
 
Space pants. Tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic