CSS for Java apps?

P

petermichaux

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
 
A

Andrew McDonagh

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

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
 
J

James McGill

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
 
T

Thomas Hawtin

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
 
C

Chris Uppal

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,431
Messages
2,571,678
Members
48,796
Latest member
Greg L.

Latest Threads

Top