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 6068525
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T09:43:27+00:00 2026-05-23T09:43:27+00:00

I would like to show a list of panels containing components, i.e a checkbox,

  • 0

I would like to show a list of panels containing components, i.e a checkbox, labels, buttons, all on the same horizontal line; each panel represents one set of components to display information for one item.
I need to put the list of panels (number undetermined) inside a scrollpanel to fit within the main panel height.

I can’t seem to find a solution for mixing scrollpanel and panels with components.

I’d like to get this result :

scrollpanel {

  • checkbox | item1 | button1 | button1 | label1 | label1
  • checkbox | item2 | button2 | button2 | label2 | label2
  • checkbox | item3 | button3 | button3 | label3 | label3

    [ … ]

}

There is a working example of what I have currently shown here :
Groovy SwingBuilder : button to change the color of a panel

There, you can see there are 6 items, each one with their respective components relating to it.
Now if I wanted to display 60 items instead of 6, the frame would expand to fit them but exceed the screen size.

I seems so obvious to me that kind of a “scrollpanel” would do the job, but I can’t get it working, although I checked all examples on the Java tutorials and the related questions here.

tia.
Michel

  • 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-05-23T09:43:28+00:00Added an answer on May 23, 2026 at 9:43 am

    You can put the panels inside a vbox, which in-turn you put inside a scrollPane.

    Taking the code from the previous question, you end up with something like this:

    import groovy.swing.SwingBuilder
    import javax.swing.WindowConstants as WC
    import javax.swing.JOptionPane
    import javax.swing.JScrollPane
    import javax.swing.BoxLayout as BXL
    
    int numPanels = 20
    
    swing = new SwingBuilder()
    frame = swing.frame(title:'test', pack:true, visible:true, defaultCloseOperation:WC.HIDE_ON_CLOSE) {
      panel(id:'mainPanel'){
        scrollPane( verticalScrollBarPolicy:JScrollPane.VERTICAL_SCROLLBAR_ALWAYS ) {
          vbox {
            (1..numPanels).each { num ->
              def panelID = "panel$num"
              def pane = panel( alignmentX:0f, id:panelID, background:java.awt.Color.GREEN ) {
                label('description') 
                textField( id: "description$num", text:panelID, columns: 70 )
                button( id: "buttonpanel$num", text:panelID, actionPerformed:{
                  swing."$panelID".background = java.awt.Color.RED
                } )
              }
            }
          }
        }
    
        boxLayout(axis: BXL.Y_AXIS)
        panel(id:'secondPanel' , alignmentX: 0f){                       
          button('Quit', actionPerformed:{
            frame.visible = false
          })
        }
      }       
    }
    frame.size = [ frame.width, 600 ]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

All, I would like to show a divider in a list and want to
Hello I would like to show a list of all messages with the date
I would like to show a list of all post tags ordering them by
What I would like to do is show the installer user a list of
I would like to show a list of tags on a post but without
I have list of hyperlinks on a webpart and i would like to show
I would like to know how to list all functions of a Clojure namespace.
I have a list of possible tagwords, and I would like to show them
In my web application, I would like to show a list of my users.
I would like to show list of emotion icons / smiley icons when tap

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.