Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / GUI / November 2007

Tip: Looking for answers? Try searching our database.

Screen Resolution

Thread view: 
Abdelali Adil - 20 Nov 2007 14:44 GMT
Hello ,

how can i listen to screen's resolution change?

thanks for your help.
Andrew Thompson - 20 Nov 2007 23:30 GMT
...
>how can i listen to screen's resolution change?

I do not know of any 'event' fired in case of screen resolution
change, but you might start a Thread (or Runnable or
javax.swing.Timer) and check the screen resolution against
a cached 'last known size'.

Why is it important to know?

BTW - the word 'I' should always be uppercase, and each
sentence should also start with a single upper case letter.

Signature

Andrew Thompson
http://www.physci.org/

Abdelali Adil - 21 Nov 2007 10:44 GMT
> Andrew Thompson wrote:

> Why is it important to know?

I am writing a GUI without layout manager, this GUI should support 2
resolutions.
Therefor It could be nice if can listen to a resolution's change.

Thanks
RedGrittyBrick - 21 Nov 2007 11:42 GMT
>> Andrew Thompson wrote:
>
>> Why is it important to know?
>
> I am writing a GUI without layout manager,

That's interesting. Why are you not using a layout manager?
Andrew Thompson - 21 Nov 2007 13:12 GMT
>>> Andrew Thompson wrote:
>>
[quoted text clipped - 3 lines]
>
>That's interesting. Why are you not using a layout manager?

I agree about the interesting part.  I am a strong advocate of the
fact that if there is any complexity whatsoever in a custom layout,
it should be encapsulated (written, coded) in a LayoutManager.

( Definining a custom layout manager is a lot easier than most
people think. )

OTOH - a lot of the things people expect can only be provided
by a custom LM (or a null LM) can coded using Sun standard
LMs, just by using 'nested layouts'.

Signature

Andrew Thompson
http://www.physci.org/

Abdelali Adil - 21 Nov 2007 16:41 GMT
> I agree about the interesting part.  I am a strong advocate of the
> fact that if there is any complexity whatsoever in a custom layout,
[quoted text clipped - 6 lines]
> by a custom LM (or a null LM) can coded using Sun standard
> LMs, just by using 'nested layouts'.

You 're right, but in my case it's only a prototype.
Daniel Pitts - 21 Nov 2007 19:29 GMT
>> I agree about the interesting part.  I am a strong advocate of the
>> fact that if there is any complexity whatsoever in a custom layout,
[quoted text clipped - 8 lines]
>
> You 're right, but in my case it's only a prototype.

If its only a prototype, what about using a GUI builder?

In any case, you don't really care about screen resolution as much as
you care about component size, correct?  Look at ComponentListener, it
can receive an event when the component changes size. (assuming you add
it to the correct component :-) )

Signature

Daniel Pitts' Tech Blog: <http://virtualinfinity.net/wordpress/>

Abdelali Adil - 22 Nov 2007 11:05 GMT
>If its only a prototype, what about using a GUI builder?

I used a GUI builder and i used null LM.
RedGrittyBrick - 22 Nov 2007 14:36 GMT
>  >If its only a prototype, what about using a GUI builder?
>
> I used a GUI builder and i used null LM.

But why?

I use a layout manager for even the simplest prototypes. In a spirit of
learning, I'd be really interested in hearing more about circumstances
where a layout manager doesn't make development faster (and the
prototype more reliable, especially if the screen resolution changes).

Please explain.
Abdelali Adil - 23 Nov 2007 10:41 GMT
>>  >If its only a prototype, what about using a GUI builder?
>>
[quoted text clipped - 8 lines]
>
> Please explain.

Well, this GUI was quite complex therefor Gridbag LM would be the solution,
but as maybe you know
Gridbag LM isn't only one of the most powerfull LM but also one of most
complex LM and you will need much more time as if you use GUI builder with
null Layout.
Andrew Thompson - 23 Nov 2007 11:33 GMT
>>>  >If its only a prototype, what about using a GUI builder?
>>>
[quoted text clipped - 7 lines]
>complex LM and you will need much more time as if you use GUI builder with
>null Layout.

But you spend much more time trying to figure how
to attach ComponentListener(s) or monitoring a 'DPI
change' rather than simply allowing a LayoutManager
(or LayoutManager*s* in the case of a nested layout)
to figure how to distribute the available space amongst
the components.

I did an experiment since this thread started, changing
my 96 DPI Widows computer to 120 DPI.  Every one of
my GUIs (using standard J2SE Layouts) looks entirely
logical to the new DPI, without any need of 'knowing'
either the screen size, or DPI.  Note that this 'logical'
look is more a testament to the clever people that designed
the layouts, than anything to do with me - I just invoked
their (well designed) logic in my GUIs.

Signature

Andrew Thompson
http://www.physci.org/

Andrew Thompson - 23 Nov 2007 11:39 GMT
>>>>  >If its only a prototype, what about using a GUI builder?

Can you give us an idea of what this GUI is supposed
to look like*?  I (almost) guarantee it is possible to code
it using standard J2SE Layouts.

*One tricky aspect is that it is important for us to understand
how 'space' in the GUI will be 'redistributed' when the GUI
is resized.  For example, what componets get 'the rest of
the space' when there is extra space to give to the GUI?

Signature

Andrew Thompson
http://www.physci.org/

Abdelali Adil - 23 Nov 2007 16:23 GMT
> Andrew Thompson wrote:
>>>>>  >If its only a prototype, what about using a GUI builder?
>
> Can you give us an idea of what this GUI is supposed
> to look like*?  I (almost) guarantee it is possible to code
> it using standard J2SE Layouts.

You are right , you can do the almost of things by combining many LMs, But
in my case it was only a matter of time.
RedGrittyBrick - 23 Nov 2007 14:58 GMT
>>> I used a GUI builder and i used null LM.
>>
[quoted text clipped - 13 lines]
> complex LM and you will need much more time as if you use GUI builder
> with null Layout.

I agree GridBagLayout is complex (and quirky). That is why I often use
* Nested layouts (e.g. BoxLayout inside BoxLayout)
* MigLayout. More powerful than GridBagLayout, easier, free and concise.

A simple example from http://www.miglayout.com/QuickStart.pdf

+-----+-------------+-----+
|comp1|             |comp3|
+-----+    comp2    +-----+
|comp4|             |comp5|
+-----+--------+----+-----+
|comp6|  comp7 |    |     |
+-----+--------+----+-----+

panel = new JPanel(new MigLayout());
panel.add(comp1);
panel.add(comp2, "span 2 2");
panel.add(comp3, "wrap");
panel.add(comp4);
panel.add(comp5);
panel.add(comp6);
panel.add(comp7);

I doubt I could do that as easily using a null layout. YMMV

Sizes can be specified in units that take DPI into account (points ,cm,
inches etc) It also has "logical pixels" which caters for varying sizes
of "normal" font on the platform.

You can specify which components grow to grab available space as the
container is resized (weighted, grouped), alignment, insets, equalize
button sizes, etc etc etc. It can mimic flowlayout and borderlayout as
well as grid oriented layouts.

It can also do absolute positioning, or a mix!

I added MigLayout's source to my workspace, so using and deploying is ,
for me, the same as for any standard layout manager.

Note: I'm not associated with Mig in any way other than as a happy user
of MigLayout.
Karsten Lentzsch - 26 Nov 2007 08:45 GMT
> [...]
> Gridbag LM isn't only one of the most powerfull LM but also one of most
> complex LM and you will need much more time as if you use GUI builder
> with null Layout.

Although GridBagLayout is complex, it is one of
the weaker Java layout managers.

Since this has been mentioned in this thread:
I've found in layout courses that most developers
end up with better design if they use a flat
grid-based layout and avoid nesting.
There are design-cases where nesting makes sense;
as a general guideline it should be avoided in
Swing, because otherwise you loose layout constraints
required for aligning (sub-)elements. Swing LMs
do not provide inter-panel layout constraints.

I've also found in the layout courses that many
developers face problems with building a mental
layout when reading layout code that mixes the
design specification with the panel building.
That's the case for GridBagLayout and how
MIGLayout is advertised. If you have 50 components,
even the last constraint can change the number
of columns.
In contrast TableLayout has invented a style where
the developer can understand the layout specification
by reading a few lines of code. That's the fixed part.
The longer panel building part does not affect
the overall design (columns, often rows).

I provide a free and open layout system that aims
to address the needs of developers as well as the
requirements for useable visual tools, the JGoodies
Forms. It has been designed to make it easier to
find a layout (it's grid based), and to implement
with hand or tool. The JGoodies FormLayout has visual
plugins for Eclipse, Netbeans and is integrated with
IDEA.

Here's more information:
http://www.jgoodies.com/freeware/forms/index.html

-Karsten Lentzsch


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.