Fandom

Programmer's Wiki

Groovy.swing.SwingBuilder

408pages on
this wiki
Add New Page
Talk0 Share

Swingbuilder is a DSL that makes constructing Swing interfaces much easier to use than when using them in Java


Example Edit

This example script creates a frame with a scrolling textarea and a button.

import java.awt.*
import groovy.swing.SwingBuilder
import java.awt.BorderLayout

def BL = new BorderLayout()

def swing = new SwingBuilder()
    frame = swing.frame(title:'Frame', size:[300,300], layout:new BorderLayout()) {
        scrollPane(constraints:BL.CENTER){
            textArea()
        }  
        panel(constraints:BL.SOUTH){
            button(text:"Hello", actionPerformed:{println "Hello"})
        }
    }

    frame.show()

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.