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 / General / February 2006

Tip: Looking for answers? Try searching our database.

CSS for Java apps?

Thread view: 
petermichaux@yahoo.com - 18 Feb 2006 19:14 GMT
Hi,

I'm just learning about Java GUI but it has immediately struck me that
in the books I'm reading there is no separation between content and
display. The size of the button is embedded in the code. This
separation is encourage/stressed in web page design with the HTML
defining the content and the CSS defining the appearance. Do people do
something similar to CSS for their Java GUI's?

Thanks,
Peter
Andrew McDonagh - 18 Feb 2006 19:22 GMT
> Hi,
>
[quoted text clipped - 7 lines]
> Thanks,
> Peter

almost all don't.

but all should.

We even have design patterns to help us: MVC, MVP, Humble Dialog Box,
Observer, Etc.

The display code is still in Java, but its only concerned with display
not content.

However, recently there have been a few none java gui rendering
tools/techniques appearing: xaml, xul, etc

Andrew
Thomas Hawtin - 18 Feb 2006 19:37 GMT
> I'm just learning about Java GUI but it has immediately struck me that
> in the books I'm reading there is no separation between content and
> display. The size of the button is embedded in the code. This
> separation is encourage/stressed in web page design with the HTML
> defining the content and the CSS defining the appearance. Do people do
> something similar to CSS for their Java GUI's?

It's unusual to set fixed sizes, colours, fonts, etc., for standard
widgets. If an application program started setting those sort of
attributes, the widgets would look very out of place. Most appearance
details is handled by the Pluggable Look & Feel (PL&F).

There are properties set on widgets by the application program that are
locale dependent. Labels, mnemonics, that sort of thing. It's easy
enough to write methods that applies properties read from a properties
file to a widget with a given name.

Most programmers seem to take a ball of mud attitude to GUI programming.
I prefer to use layers. The top layer just lays out components. The
layer beneath creates components. Another layer manages the underlying
models.

Tom Hawtin
Signature

Unemployed English Java programmer
http://jroller.com/page/tackline/

James McGill - 18 Feb 2006 19:44 GMT
> Hi,
>
> I'm just learning about Java GUI but it has immediately struck me that
> in the books I'm reading there is no separation between content and
> display.

If you're seeing tight coupling it is probably because the book is
keeping examples simple.

Separating the objects from the presentation is what the LayoutManager
interface is all about.

> Do people do
> something similar to CSS for their Java GUI's?

Swing has "Look&Feel" that parameterizes widget behavior and drawing
down-to-the-metal.

Here's an article where the author maps the CSS idea onto Swing:

http://today.java.net/pub/a/today/2003/10/14/swingcss.html
Chris Uppal - 19 Feb 2006 11:12 GMT
> I'm just learning about Java GUI but it has immediately struck me that
> in the books I'm reading there is no separation between content and
> display. The size of the button is embedded in the code.

That might be because the book has to keep examples simple.  OTOH, it could be
bad code in that it hard-codes layout at the pixel level (but that could also
be in order to keep things simple until it gets to layout managers in some
(hypothetical) later chapter -- but I would still call it a bad example, even
so).

But, to the extent that the book's examples are representative of real code, I
hope you'll find that that stuff /is/ display.  Only display.  Content is -- or
damn-well should be -- handled elsewhere.

   -- chris


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.