Search code examples
groovytextareascrollpaneswingbuilder

Groovy Swingbuilder: How can i add a scrollpanel to my frame?


I want to add a scrollpane, which contains a textarea, but I don't know how. So I searched the internet and found some examples, but none of them helped me.

This is some of my code:

frame = sb.frame(title:"BPNM Builder", size:[600, 400],defaultCloseOperation:WindowConstants.EXIT_ON_CLOSE){

panel(id:'mainpanel',border:BorderFactory.createEmptyBorder(10,10,10,10)){
    gridBagLayout()
    
       
    label(
            text:"out:",
            constraints: gbc(gridx:0,gridy:0,fill:HORIZONTAL,insets:[0, 0, 323, 0])
            )

    textArea(
            id:'liste',"commands:\n" + ml.opList,preferredSize:new Dimension(200,180),
            constraints:gbc(gridx:1,gridy:0,gridwidth:REMAINDER,fill:VERTICAL,insets:[20, 300, 85, 0])
            ,editable:false
            )
            
    textArea(
            id:'outline',preferredSize:new Dimension(350,140),
            constraints:gbc(gridx:0,gridy:0,gridwidth:REMAINDER,fill:VERTICAL,insets:[20, 0, 85, 200])
            ,editable:false, lineWrap:true, wrapStyleWord:true
            )

Could somebody tell me, how I can add a scrollpane to my frame, containing textareas?

Thanks in advance!


Solution

  • Just embed the textAreas in a scrollPane:

    scrollPane(constraints:gbc(gridx:1, gridy:0, gridwidth:REMAINDER, fill:VERTICAL, insets:[20, 300, 85, 0])) {
        textArea(id:'liste', "commands:\n" + ml.opList,editable:false)
    }