Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 2 Next »

CSSBuilder is a Groovy builder for styling a Swing application with CSS

Contribution Overview

CSSBuilder is based on Swing Clarity, a framework created by Ben Galbraith. It makes styling a Swing application with CSS a breeze.

Team Members

Andres Almiray [aalmiray at users dot sourceforge dot net]

Download

cssbuilder-0.1

Installing

Drop cssbuilder-0.1 into $GROOVY_HOME/lib along with its dependencies

Pre-requisites

Groovy 1.6.0 is the required minimum version to run CSSBuilder 0.1
It is recommended that you upgrade to the 1.6.x series in order to take advantage of

  • @Bindable and ASTTransformations
  • short binding syntax
  • numerous enhancements made to SwingBuilder and FactoryBuilderSupport

Documentation

CSSBuilder does not add new nodes as opposed to other popular builders, however it enhances every node with a new attribute: cssClass. Use this attribute to define (at least one) CSS class to be applied to that particular component. Additionally you can specify a name: property that will be used as a CSS id. This builder injects the following methods to the java.awt.Container class

$(String name) - performs a component lookup by name, returns a JComponent
$(String... names) - performs component lookup by names, returns a JComponent[]
$$(String selector) - performs component lookup by CSS selector, returns a JComponent[]

This is the list of currently supported CSS properties and some non-standard Swing related properties

Property

Values

Maps to

Apply to

font-family

 

setFont()

JComponent

font-size

"xx-small", "x-small", "small", "medium", "large", "x-large", "xx-large", "smaller", "larger"
or use an integer with % or pt suffix

setFont()

JComponent

font-weight

normal, bold

setFont()

JComponent

font-style

normal, italic

setFont()

JComponent

color

a CSS2 color or a hex color starting with #

setForeground()

JComponent

background-color

a CSS2 color or a hex color starting with #

setBackground()

JComponent

width

an integer value

setSize()

JComponent

height

an integer value

setSize()

JComponent

min-width

an integer value

setMinimumSize()

JComponent

min-height

an integer value

setMinimumSize()

JComponent

max-width

an integer value

setMaximumSize()

JComponent

max-height

an integer value

setMaximumSize()

JComponent

pref-width

an integer value

setPreferredSize()

JComponent

pref-height

an integer value

setPreferredSize()

JComponent

padding

a set of 1, 2, 3 or 4 integer values

setBorder()

JComponent

padding-top

an integer value

setBorder()

JComponent

padding-bottom

an integer value

setBorder()

JComponent

padding-left

an integer value

setBorder()

JComponent

padding-right

an integer value

setBorder()

JComponent

border-color

a CSS2 color or a hex color starting with #

setBorder()

JComponent

border-width

a set of 1, 2, 3 or 4 integer values

setBorder()

JComponent

border-top-width

an integer value

setBorder()

JComponent

border-left-width

an integer value

setBorder()

JComponent

border-bottom-width

an integer value

setBorder()

JComponent

border-right-width

an integer value

setBorder()

JComponent

swing-row-height

an integer value

setRowHeight()

JTable

swing-client-property

a Groovy map literal surrounded with quotes

putClientProperty()

JComponent

swing-halign

left, right, or center

setHorizontalAlignment()

JComponent

swing-valign

top, bottom or middle

setVerticalAlignment()

JComponent

You can use the following selectors:

  • * (star) will match every component
  • <classname> will match all components of that classname, example jbutton
  • #<name> matches a component by its name: attribute
  • .<class> matches a component by its cssClass: attribute

Developers

Andres Almiray

Source Control

http://svn.codehaus.org/griffon/builders/cssbuilder

Building

CSSBuilder uses Ant as its build tool, which means that if you want to
build your own version of CSSBuilder from source you'll need to have it
installed. Follow the instructions at http://ant.apache.org

Contributing

Please contact the team members by e-mail.

Community

Mailing List(s)

http://griffon.codehaus.org/Mailing+Lists

Issue tracker

http://jira.codehaus.org/browse/GRIFFON

  • No labels