Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8558279
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T15:46:32+00:00 2026-06-11T15:46:32+00:00

I have a standalone Swing application and I’m using Groovy as programing language. Trying

  • 0

I have a standalone Swing application and I’m using Groovy as programing language.

Trying to apply styles using CSS and searching for some tool for this purpose, I’ve found CSSBuilder.

The problem is that CSSBuilder comes integrated with Griffon framework, so I cannot use all of its features isolated from Griffon, such as ‘cssClass’ selector.

Therefore my question is simply: has anyone managed to do something like this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T15:46:33+00:00Added an answer on June 11, 2026 at 3:46 pm

    Just wrote a quick test, and this seems to work:

    @GrabResolver( name='codehaus', root='http://repository.codehaus.org' )
    @Grab( 'org.codehaus.griffon:cssbuilder:0.4' )
    import griffon.builder.css.*
    import groovy.swing.SwingBuilder
    import java.awt.BorderLayout as BL
    
    def style = '''* {
      background-color: red;
    }
    
    jbutton {
      background-color: blue;
    }
    
    .active {
      color: green ;
      font-size: 50%;
    }
    
    jlabel {
      color: pink ;
      font-size: 200% ;
    }'''
    
    Class klass = javax.swing.JComponent
    if( !AbstractSyntheticMetaMethods.hasBeenEnhanced(klass) ) {
       AbstractSyntheticMetaMethods.enhance(klass,[
          "getCssClass": {-> delegate.getClientProperty(ClarityConstants.CLIENT_PROPERTY_CLASS_KEY) },
          "setCssClass": { String cssClass -> delegate.putClientProperty(ClarityConstants.CLIENT_PROPERTY_CLASS_KEY, cssClass) }
       ])
    }
    
    new SwingBuilder().edt {
      int count = 0
      def frame = frame( title:'CSS Test', size:[ 300, 300 ], show: true ) {
        borderLayout()
        textlabel = label(text:"Click the button!", constraints: BL.NORTH)
        button(text:'Click Me',
             cssClass: 'active',
             actionPerformed: {count++; textlabel.text = "Clicked ${count} time(s)."; println "clicked"},
             constraints:BL.SOUTH)    
      }
      CSSDecorator.applyStyle( style, frame )
    }
    

    The meta-class enhancing code I took from the source of CSSBuilder

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a standalone java application that fires up several JMS consumers using the
I have designed a standalone application using swings which can read data from HID
I am developing a standalone application in Java using swing API. I need experts
I have an assignment to create a java Swing application to do some stuff
I am working on a standalone swing application.I have created trees by taking the
When i am using net beans to develop one standalone swing application which is
I have implemented a standalone java application which uses the swing framework for GUI.As
I have a standalone (3rd party) app that I'm trying to launch using a
I'm developing Swing standalone application using Maven. I try to follow MVC pattern. I'm
I have a standalone application which I have deployed using the Maven release plugin.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.